Ah, the event also has the object yo. Programmers have been talking about object objects, so, is it time to bring an object home for the new year?
Well, since the event has an object, admit the fact! Haha, then, it has attributes, next, put a
For example, by the way, the commonly used attributes are added.
The event object represents the state of the incident, such as the element in which the event occurred, the state of the keyboard key, the position of the mouse, and the state of the mouse button.
Events are often used in conjunction with functions, and functions are not executed until the event occurs
<! DOCTYPE html> <script> window.onload = function () {var bt = document.getElementById ("btn"); Bt.onclick = FF; Bt.onmouseover = FF; } function ff (EVN) {var di = document.getElementById ("Do"); if (window.event) {EVN = window.event}/* Event object, compatible with IE, event object is an attribute of IE/if (Evn.type = = "click") {/* The custom EVN here is treated as an object, here, Determine the EVN event object's Operation Event mode */di.innerhtml+= "click<br>"; } else if (Evn.type = = "MouseOver") {di.innerhtml+= "mouseover<br>"; }/* is followed by some of the common properties of the event object */Console.log (Evn.button);/* Event Object Button Property */Console.log (EVN.TYPE);/* Event Object Type Property */Console.log (E VN.CLIENTX);/* Event Object ClientX Property event occurs when the mouse is positioned relative to the upper-left corner of the viewable document area of the browser window */console.log (evn.clienty);/* Event Object ClientY Properties */ Console.log (EVN.OFFSETX); */* Event Object OffsetX Property event occurs when the mouse is positioned relative to the upper-left corner of the source element */Console.log (evn.offsety);/* Event Object OffsetY Properties */ Console.log (Evn.screenx);/* Event Object ScreenX Property The mouse pointer is positioned relative to the upper-left corner of the display */Console.log (Evn.screeny);/* Event Object ScreenY Properties */ Console.log (evn.target.nodeName);/* The Event Object target property event source is the element where the event occurred; */}</scripT></body>
JS Event Object