admin管理员组文章数量:1026989
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();
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();
本文标签: JavaScriptJQueryshow all elements by class nameStack Overflow
版权声明:本文标题:javascript - jQuery, show all elements by class name - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1739491683a1653183.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论