How to prevent event bubbling

Posted By :Himanshu Khurana |30th September 2018


This is the syntax to use this method:

event.stopPropagation();

Example

Stop tr click function on fourth td. Use the below code for stops bubbling of an event to parent elements.

HTML

 <table>
   <tr ng-click="click()">
     <td>1</td>
     <td>2</td>
     <td>3</td>
     <td ng-click="fourthClick($event)">4</td> 
     <td>5</td> 
   </tr>
</table>

Angular/Javascript

$scope.fourthClick = funtion(){
  event.stopPropagation();
}

 

I hope this blog will help for all.

THANKS


About Author

Himanshu Khurana

Himanshu is an experienced Frontend developer with experience and capabilities to build compelling UI's for Web and Mobile Applications. Himanshu likes playing cricket and listening music.

Request For Proposal

[contact-form-7 404 "Not Found"]

Ready to innovate ? Let's get in touch

Chat With Us