I had a strange problem in firefox where the click event appears in a node document when I right-click on a child of a node element.
This code illustrates the problem: http://jsfiddle.net/RyDZU/5/
Updated version: http://jsfiddle.net/RyDZU/10/
$(document).on("click","span",function(e) { console.log('span'); console.log(e.isPropagationStopped()); }); $(document).on("click","div",function(e) { console.log('div'); console.log(e.isPropagationStopped()); e.stopPropagation(); console.log(e.isPropagationStopped()); }); $(document).on("click",function(e) { console.log('body'); console.log(e.isPropagationStopped()); });
HTML: <& DIV GT; <& duration GT; Test </ & duration GT; </DIV>
If you right-click the word "test", the word "body" will be printed in the console on firefox (21). Not in IE 10 / Chrome.
How can I prevent this event in Firefox?
This does not work:
$("body").on("click", "span", function(e) { e.preventDefault(); e.stopPropagation(); });
source share