Phil
Phil

Reputation: 7607

Nested menu stop triggering not directly clicked <li>s

I have built an expandable, nested menu in <ul> <li> <ul> <li> style in HTML. Both, the upper and lower <li>s have an onCLick attribute. when clicking on the lower (nested) li, the upper li should not trigger onClick or at least submit to the handler, that it was activated indirectly.

How do I achieve this?

Upvotes: 0

Views: 92

Answers (1)

user6483357
user6483357

Reputation:

I think this will help you:

$(document).ready(function(){
    $(".header").click(function(){
        $(this).children(".children").toggle();
    });
   $(".header a").click(function(e) {
        e.stopPropagation();
   });
});

If it dont: Send me a message

Upvotes: 1

Related Questions