开发者

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();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜