Web APIs
Event.stopPropagation()
Stops propagation to other targets without canceling the default action or other listeners in the current invocation group.
Formal Syntax & Structure
javascript syntaxjavascript
event.stopPropagation()Return Value
undefined
No return value.
Working Example
Example Snippetjavascript
const p=document.createElement("div"),b=document.createElement("button");p.append(b);b.addEventListener("click",e=>{e.stopPropagation();console.log("first");});b.addEventListener("click",()=>console.log("second"));p.addEventListener("click",()=>console.log("parent"));b.click();