Reputation: 241
I have a main div <div id="divMain">
, under which I've multiple divisions. But, I'm trying to display only few div's say <div id="div3"> & <div id="div4">
and hide other inside divMain. I'm not getting it. Any ideas would be greatly appreciated.
Upvotes: 1
Views: 272
Reputation: 82231
You can use :not
selector to filter out hiding few elements using their selector:
$('#divMain div:not(#div3,#div4)').hide();
In case you have inner divs in div3 and div4, you can use:
$('#divMain div:not("#div3,#div4,#div3 *,#div4 *")').hide();
Upvotes: 3
Reputation: 148110
First hide all div
in divMain
and then show the few you want using the Multiple Selector (“selector1, selector2, selectorN”).
$('#divMain div').hide();
$('#div3, #div4').show();
Upvotes: 2