Archana Kumari Archana Kumari - 1 year ago 96
Javascript Question

Prevent the click event on the parent div

<div class="usersDiv">
<ul class="users">

I have an li element inside an div element.I have written Jquery that when user click on the div a different event happened and when user click on li of div a different event will happen. But the problem is when user click on li element, both the click event on li and div are called, i also used preventDefault() method on li click, but it doesn't works. How to prevent the click on div element when i click on li element? Thanks in advance.

Answer Source

You should use, it will prevent the parent behavior to be executed


You can refer this link for more details e.stopPropgation