开发者

Hiding multiple elements of a specific class or ID using jquery

I would like to know if its possible to hide all the HTML elements (divs in my case) with a specific class name or ID using jquery.

Thanks

Thanks for the sympathy, I already know the hide() function but the problem is there are multiple divs which I want hidden but the my code only works on the first on or doesnt work at all. Below is my code

$(document).ready(
                            $(".list").hide();                                
                            function divToggle() 
                            { 
                              $(this).children("div.list").slideToggle("fast");
                            });

Please assist me in finding what I'm doing wrong.

And Thanks f开发者_JAVA技巧or your patience


Yes, you can use a .class selector and .hide():

$(".class").hide();

or an #id selector (when hiding a single element):

$("#id").hide();

But the ID selector should be unique, so in the case of $("#id") you shouldn't be trying to select multiple elements...that's definitely a situation for classes.


jQuery('.specific, #specific').hide();


You can hide multiple class also For example,

jQuery('.class1, .class2').hide();

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜