< div id= "one" onclick= "alert (' I am outermost ');" >< div id= "onclick=" alert (' I am the middle tier '); >< a id= "Hr_three" href= "http://www.baidu.com" onclick= "alert (' I'm the innermost ');" > Click me < /a ></div ></div >
1.event.stoppropagation ();
Event bubbling is blocked during event processing, but the default behavior is not blocked (it performs a hyperlink jump)
2.return false;
Event bubbling is blocked during event processing, and the default behavior is also blocked (for example, a jump that did not perform a hyperlink just now)
There is also a bubbling-related:
3.event.preventdefault ();
If you put it in the Click event of the head a tag, click "Click Me".
Will find it pop up in turn: I am the innermost----> I am the middle tier----> I am the outermost, but finally did not jump to Baidu
Its role is: During event processing, do not halt the event bubbling, but the default behavior (it only executes all the bullets, but did not perform a hyperlink jump)
4.The difference between this and event.target:
The event in
JS is bubbling, so this is changeable, but Event.target does not change, it is always the target DOM element that directly accepts the event;
the same point of this and event.target:
This and Event.target are DOM objects, and if you want to use the methods in Jquey, you can convert them to jquery objects: $ (this) and $ (event.target);
Compatibility function for 5.js event handling: var eventutil = { addhandler:function (element, type, handler) { if ( Element.addeventlistener) { Element.addeventlistener (type, handler, false); } else if ( element.attachevent) { element.attachevent ("on" + type, handler); } else { &N Bsp Element["on" + type] = handler; } }, removehandler:function (element, type, handler) {   ; if (Element.removeeventlistener) { Element.removeeventlistener (type, handler, false); } else if (element.detachevent) { element.detachevent ("on" + type, handler); } else {  ; element["on" + type] = null; } }, getevent:function (event) { return EV Ent? event:window.event; }, gettarget:function (event) { return Event.target | | event.srcelement;& nbsp }, preventdefault:function(event) { if (event.preventdefault) { Event.preventdefault (); } else { & nbsp Event.returnvalue = false; } }, stoppropagation:function (event) { if ( event.stoppropagation) { event.stoppropagation (); } else { event.cancelbubble = true; }};
Block event bubbling