bonaca bonaca - 2 months ago 6x
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.


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.