JavaScript MouseEvent movementY Property
You are Here:
JavaScript MouseEvent movementY Property
The event.movementY
property returns the difference in the Y coordinate of the mouse pointer between the given event and the previous mousemove event.
Formula: currentEvent.movementY
= currentEvent.screenY - previousEvent.screenY
Note: This property is read-only.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<div onmousemove="myFunction(event)">
<p>Move cursor anywhere within this div</p>
<p id="point"></p>
</div>
<script>
function myFunction(e){
var xCoords = e.movementX;
var yCoords = e.movementY;
var result = "X coords = "+xCoords+" ,Y coords = "+yCoords;
document.getElementById("point").innerHTML = result;
}
</script>
</body>
</html>
Syntax
event.movementY
Return Value
Value | Explanation |
---|---|
Number | A number representing the horizontal coordinate of the mouse pointer relative to the position of the padding edge of the target node. |
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.