event.stopPropogation not working as expected -
as know event.stoppropogation() used stop event bubbling i.e stop firing parent events in code it's not working. can please check that.
<div onclick="diva();"> div <p onclick="pa();"> ppp <a onclick="aa();"> hello </a> </p> </div> <script type="text/javascript"> function diva(){ alert('div') } function pa(){ alert('p') } function aa(event){ event.stoppropogation(); alert('a') } </script>
it's alerting p , div while should alert a.
your event undefined .pass event follows :
<a onclick="aa(event);">
function diva(){ console.log('div') } function pa(){ console.log('p') } function aa(event){ event.stoppropagation(); console.log('a') }
<div onclick="diva();"> div <p onclick="pa();"> p <a onclick="aa(event);"> hello </a> </p> </div>
Comments
Post a Comment