js event stop bubbling code example

Example 1: stop propagation event

$("span").click(function(event){
  event.stopPropagation();
  alert("The span element was clicked.");
});
$("p").click(function(event){
  alert("The p element was clicked.");
});
$("div").click(function(){
  alert("The div element was clicked.");
});

Example 2: javascript event stoppropagation

event.stopPropagation();

Example 3: js propagation stop

<div (click)="func($event)">
	<span>oi</span>
</div>

func(e?)
{
	if(e) e.stopPropagation();
}

Example 4: how to prevent event capturing in javascript

how to prevent event button click capturing to tag/div/icon
easiest way OPTION 1 with CSS:
button > * {
  pointer-events: none;
}

OPTION 2 with javascript:
use e.currentTarget.children ;

OPTION 3 with Javascript:
use e.target.closest('selector') to locate the child, not e.currentTarget;