MouseEventWhen the mouse performs a certain operation, an event object is generated, which records all the properties of the mouse when the event is triggered. You can print out the MouseEvent object in the Google console as follows. function mouseDown(e){ var e = e||event; console.log(e) } window.onload = function (){ document.getElementsByTagName('body')[0].addEventListener('mousedown',mouseDown,false) } The printed MouseEvent is as follows: This object has many properties, but the most commonly used ones are offsetX, offsetY, clientX/clientY, pageX, and pageY. What do the various attributes correspond to? The following are some common events: altkey: Whether the alt key is pressed when the mouse event is triggered, if so, returns true, otherwise returns false. button: The event attribute returns an Arabic numeral, 0 represents pressing the left button, 1 represents pressing the scroll wheel, and 2 represents pressing the right button. offsetX, offsetY: The event attributes return the X and Y coordinates of the mouse relative to the event source element when the event is triggered. Standard events do not have corresponding attributes. clientX, clientY: The event properties return the horizontal and vertical coordinates of the mouse pointer relative to the browser page (or client area) when the event is triggered. pageX, pageY: The event attributes return the horizontal and vertical coordinates of the mouse pointer relative to the upper left corner of the entire page when the event is triggered. screenX, screenY: The event attributes return the horizontal and vertical coordinates of the mouse position relative to the user's screen when the event is triggered. The reference point, or origin, is the upper left corner of the screen. Well, text descriptions are always annoying, so here’s a classic picture to explain everything: This is the end of this article about the JavaScript mouse event (MouseEvent) case study. For more relevant JavaScript mouse event (MouseEvent) content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: MySQL sliding aggregation/year-to-date aggregation principle and usage example analysis
>>: Tutorial on deploying nginx+uwsgi in Django project under Centos8
Table of contents 1. Configure bridging and captu...
Table of contents 1.1 Java environment as a prere...
1. Introduction WHMCS provides an all-in-one solu...
You can use the attribute in HTML5 <input="...
Table of contents 1. Database bottleneck 2. Sub-l...
1. Command Introduction The seq (Sequence) comman...
I see many novice students doing front-end develop...
Preface The Boost library is a portable, source-c...
This article mainly introduces: using Vue to impl...
1. The mysqldump backup method uses logical backu...
Table of contents Why use a debugger? Basic usage...
Five delay methods for MySQL time blind injection...
Generally speaking, after the container is starte...
Install MySQL database a) Download the MySQL sour...
Preface Not long ago, I saw an interesting proble...