I need to capture an event instead of giving it bubbles. This is what I need: < Pre> With this sample code, I have a click event surrounded by a divisor and body. I want the body function to be called for the first time. How can I go about this? Use Event Capturing instead: - Check the final logic for "addEventListener" by default This is incorrect and the event is in Bubbling mode. If set to true then will act as a capturing event. For cross browser implementation. Use pre-eventbulbling by IE8 and by default so I've attached the document to the document instead of the body, so you must use the event object to get the object object . You should be very difficult for IE. & lt; Body & gt; & Lt; Div & gt; & Lt; / Div & gt; & Lt; / Body & gt;
$ ( "Body"). Get (0) .addEventListener ("click", function () {}, true);
var bodyEle = $ ("body"). Get (0); If (bodyEle.addEventListener) {bodyEle.addEventListener ("click", function () {}, true); } And if (bodyEle.attachEvent) {document.attachEvent ("onclick", function () {var event = window.event;}); }
No comments:
Post a Comment