- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Select a Parent Element whose Children are Hidden
Myself Jaffar,
I’m a UI Designer,
I need a parent selector (i want to hide this element) with all its hidden children, my html code follows:
/* all children hidden*/
<div class="CLRow">
<div class="CLCell" style="display:none;">cell one</div>
<div class="CLCell" style="display:none;">cell one</div>
</div>
/* one child hidden and another is visible*/
<div class="CLRow">
<div class="CLCell" style="display:none;">cell one</div>
<div class="CLCell" style="display:block;">cell one</div>
</div>
— thanks in advance :)
So if an element has all it’s children hidden, you want to select it and hide it.
If any of the children aren’t hidden it isn’t going to be selected.
Is that right?
Nice even if I don’t quite ‘grok’ Jquery quite yet.
CSS…not possible as there is no ‘parent’ selector.
Hi All,
Thanks for the Reply,
Reply @ Paulie_D: Yes, I want to hide a Parent if its children are hidden.
Reply @ MattDiMu: I need Jquery Solution as there is no CSS selector for parent element yet. Thanks for Solution.
And i just myself found a solution please checkout :
I’ve used length as ‘2’ coz i have only two children in this case :)
$('.CLRow').each(function () {
if ($(this).children(':hidden').length == 2){
$(this).hide(); }
});
Thanks for info.