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?
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?
Share Improve this question asked Aug 31, 2010 at 19:49 There Are Four LightsThere Are Four Lights 1,4263 gold badges20 silver badges35 bronze badges 1- 4 5 answers and all the same. Must be correct :) – Marko Commented Aug 31, 2010 at 19:52
5 Answers
Reset to default 7$("." + 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();