Forums

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

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #175630
    JaffarKhan
    Participant

    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 :)

    #175632
    Paulie_D
    Member

    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?

    #175651
    Paulie_D
    Member

    Nice even if I don’t quite ‘grok’ Jquery quite yet.

    CSS…not possible as there is no ‘parent’ selector.

    #175962
    JaffarKhan
    Participant

    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(); }
                });
    #176324
    JaffarKhan
    Participant

    Thanks for info.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.