jQuery, show all elements by class name
I want to show all elements with some class name (string). Something like:
var somevar = "apple"
$( .... select all ele开发者_Go百科ments with class == somevar ).show();
How can it be done?
$("." + somevar).show()
I think it should be as simple as
$('.' + somevar).show();
$("." + somevar).show();
$(document).ready(function(){
var somevar = ".apple"
$(somevar).show();
});
That will show .apple
OR
$(document).ready(function(){
var somevar = "apple"
$('.' + somevar).show();
});
$('.'+somevar).show();
精彩评论