tags:

views:

56

answers:

2

Hi,

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 for your patience

+4  A: 

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.

Nick Craver
Also $('div.[class]').hide(); would work if you just want divs.
JoshNaro
A: 
jQuery('.specific, #specific').hide();
David Dorward