Previously know that there are events bubbling, but has been encountered, today the revision program finally met. Now summarize the points
1: What is called event bubbling
There are 2 kinds of events in the JS time processing mechanism, capturing event events and bubbling events. The bubbling event is the same event that starts from the event source and then calls the previous layer, knowing the Window object. Capturing events happens to be the opposite.
2: Several ways to block event bubbling:
A: Returns false directly at the end of the event function in jquery
$ ("form"). Bind ("Submit", function () {return false; } );
B: Original JS blocking event bubbling
function Stopeventbubble (event) { var e=event | | window.event; if (e && e.stoppropagation) { e.stoppropagation (); } else{ e.cancelbubble=true; } }
C: Block Browser default events
var el = window.document.getElementById ("a"); El.onclick = function (e) { //If an event object is provided, this is a non-ie browser if (e && e.preventdefault) { //block default browser action (web) C4/>e.preventdefault (); } the way to block the default action of a function in the else {//ie window.event.returnValue = false; return false; } }
Block event bubbling