jQuery first element of type click

I am working through an issue where I have a menu that is mutli levels deep. I am trying to get it so that if a first level element is clicked (add class .ubermenu-active) it will look for any other first level element with that class and remove it.

    $('.ubermenu-item-level-0 span').on('click',function() {
       var target = $('.ubermenu-item-level-0');
       $('.ubermenu li.ubermenu-item-level-0').removeClass('ubermenu-active');
       target.parents('.ubermenu li.ubermenu-item-level-0').toggleClass('ubermenu-active');
    });

Right now if any of the sub elements are click t

Read more here: jQuery first element of type click

Leave a Reply

Your email address will not be published. Required fields are marked *