July 25, 2010 by Christoff Truter JavaScript
Observe the following markup:
<script type="text/javascript"> function message(text) { alert(text); } </script> <div style="width:100px"> <div style="background-color:red; padding:10px;" onclick="message('a')"> <div style="background-color:green; padding:10px;" onclick="message('b')"> <div style="background-color:blue; padding:10px;" onclick="message('c')"> </div> </div> </div> </div>
function StopPropagation(e) { if (window.event) { e.cancelBubble=true; // IE } else { e.stopPropagation(); // Others } }
function message(text, e) { alert(text); StopPropagation(e); }
<div style="width:100px"> <div style="background-color:red; padding:10px;" onclick="message('a', event)"> <div style="background-color:green; padding:10px;" onclick="message('b', event)"> <div style="background-color:blue; padding:10px;" onclick="message('c', event)"> </div> </div> </div> </div>
April 9, 2015
JavaScript Tip - BenchmarkingJanuary 7, 2015
Works in Firefox December 1, 2010 by Christoff Truter
Works 100% in firefox, what issues are you experiencing?