$('.header-submenu__list ul.ul-list > li').on('click',function(){ $(this).children('.h-dropdown').addClass('active') }) $('.h-dropdown__prev').on('click',function(){ $(this).parent('.h-dropdown').removeClass('active') }) 

The problem is that .h-dropdown__prev is in .header-submenu__list ul.ul-list> li and when I need to remove a class, it deletes and then re-adds because the first event works again. How can you make this conflict happen?

    1 answer 1

    Try to stop the spread of the event.

     $('.h-dropdown__prev').on('click',function(event) { event.stopImmediatePropagation(); $(this).parent('.h-dropdown').removeClass('active'); }); 
    • Thank you very much - Daniel qwaqwaqwa