开发者

jQuery, show all elements by class name

开发者 https://www.devze.com 2023-01-13 17:59 出处:网络
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();

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

精彩评论

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