Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Show/Hide child Divs onChange

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #172082
    Harun
    Participant

    Here is my pen:
    http://cdpn.io/jEkKz

    I am trying to unhide “success” note (hidden inside the green bar) when we change the combo box option.

    $('select').on('change', function() {
        $(this).closest('.success').removeClass('hide');
    });
    

    The above jQuery code doesn’t seem to do the trick.
    Please help.

    #172087
    Paulie_D
    Member

    I’m no Jquery expert but doesn’t .closest search UP the DOm…not down?

    http://api.jquery.com/closest/

    #172089
    Paulie_D
    Member
    $('select').on('change', function() {
    
        $(this).siblings('.validation').find('.success').removeClass('hide');
    
    });
    

    or just

    $('select').on('change', function() {
    
        $(this).siblings().find('.success').removeClass('hide');
    
    });
    

    http://api.jquery.com/category/traversing/tree-traversal/

    #172093
    Harun
    Participant

    Yes! I just realized I was missing the .find()

    Thanks Paulie_D !

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