e.stopPropagation()
<style>
#parent{
width: 200px;
height: 200px;
background-color: red;
}
#child{
width: 100px;
height: 100px;
background-color: yellow;
}
</style>
</head>
<body>
<div id="parent">
<div id="child">
</div>
</div>
<script>
var parent=document.querySelector("#parent")
var child=document.querySelector('#child')
parent.onclick=function(){
alert('parent')
}
child.onclick=function(e){
alert('child')
e.stopPropagation()
}
</script>