When triggering an event on the DOM, an event object is generated, which records Some information about the event. Regardless of whether the event binding is DOM0-level or DOM2-level, the event object is passed in, and when a handler is specified with an HTML attribute, the variable event holds the object, and the code is as trivial as:
var btn = document.getElementById ("button"function(event) { Console.log (event); The ///DOM0 Level binding event can print the event object }btn.addeventlistener ("click",function (event) { Console.log (event); // DOM2-level binding event can print event object })
<type= "button" onclick= "Console.log (event);" />
Different event types will have different events properties and methods, but there will still be some common properties and methods
Bubbles Property, if the event supports bubbling, the property value of this property is true otherwise false
Currenttarget Property, pointing to the element that is handling the event
JavaScript Event-Event object