'Clickable div inside another clickable div
Solution 1:[1]
I think this is the one you're looking for https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_event_stoppropagation (in this demo, you need to tick on the checkbox on UI)
You can put e.stopPropagation() in your child element's click.
According to this document
The stopPropagation() method prevents propagation of the same event from being called. Propagation means bubbling up to parent elements or capturing down to child elements.
Solution 2:[2]
You have to set stopPropagation to the second div inside the click function.
function div(event){
event.stopPropagation();
}
<div onClick='div()'>
This will solve your problem
Solution 3:[3]
Call the following methods in the click handler for the nested div, and it should stop propagation to the parent click event
e.preventDefault();
e.stopPropagation();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nick Vu |
| Solution 2 | Nikesh Kp |
| Solution 3 | Mike Irving |

