const container= document.getElementById("container")
const path = document.getElementById("myPath")
path.onclick = (event) => {
event.stopPropagation() // not working
console.log("Path clicked !")
}
container.onmousedown = (event) => {
console.log("container clicked !")
}
<div id="container">
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
<path id="myPath" d="M10 80 Q 95 10 180 80" fill="none" stroke="black" stroke-width="5" />
</svg>
</div>
When I click to path
not working event.stopPropagation()
. I just want to run alert("Path clicked !")
. But running both listeners. Where is problem in this codes ?