views:

49

answers:

5

I want to show all elements with some class name (string). Something like:

var somevar = "apple"
$( .... select all elements with class == somevar  ).show();

How can it be done?

+5  A: 

$("." + somevar).show()

stereofrog
Thanks. As far as i understand there is no other way to do that.
TJY
+2  A: 

I think it should be as simple as

$('.' + somevar).show();
nathanvda
+2  A: 
$("." + somevar).show();
Marko
+2  A: 
$(document).ready(function(){

  var somevar = ".apple"

      $(somevar).show();

});​

That will show .apple

OR

$(document).ready(function(){

  var somevar = "apple"

      $('.' + somevar).show();

});​
MoDFoX
+2  A: 

$('.'+somevar).show();

Rocket