onmousemove event

 The onmousemove event means that when the mouse cursor moves, it belongs to a type of JavaScript event . It is used to monitor whether the mouse cursor of the netizen moves in a specific area. If such a behavior pattern occurs, a specific JavaScript function is triggered. To perform specific tasks, due to the characteristics of onmousemove, designers who are just starting to learn often confuse the difference between onmouseover and onmouseover . Here is a little explanation of the difference between the two. Onmouseover is activated when the mouse moves into the monitored area, and only The function will be triggered once, and the protagonist onmousemove will trigger the function as long as the mouse moves in the monitored area. All major browsers support the onmousemove event.


Basic syntax of onmousemove event

onmousemove = "JavaScript function to be triggered"


The "JavaScript function to be triggered" in the grammar is a necessary item. Designers can put onmousemove in various web elements to monitor the behavior patterns of netizens, but the most important thing is to monitor the movement of the mouse in the area. Trigger function to perform specific work content. Here is a reminder that onmousemove will trigger the function as long as the mouse moves. Continuous triggering will affect the overall performance. You need to be cautious before using this event.

onmousemove event example
<div id="TestBox" onmousemove="alert('Mouse Move')" style="padding:5px;background-color:#FFE5B5;">
Mouse cursor moved here to test
</div>
Example output
The mouse cursor moves here to test
Whether the mouse moves into the orange test area, moves in the test area, or moves out of the test area, the alert will be triggered to display the string through the dialog window, but the effect is the same as onmouseover when the mouse is moved into the test area . The effect of the test area is the same as onmouseout , but the monitoring function of moving in the test area can only be done by onmousemove.

Post a Comment

0 Comments