bonaca bonaca - 1 year ago 60
jQuery Question

hide all child elements on multiple divs

I have four divs and want to hide all child elements on each of them.


I believe there is a better way.

Answer Source

Yes, you can do all with only one line:

$('#col1, #col2, #col3, #col4').children().hide();

If you have only these divs you may reduce all to:


In this way all divs having an id starting with col will be selected.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download