Javatpoint Logo
Javatpoint Logo

The "mousemove" Event in JavaScript

The mousemove event works when a pointer moves within the web tag or around the element. It is easy to operate mouse movement just using the point of the mouse. The mousemove event takes part in an event handler. It is an execution in the script tag to respond to a certain mouse operation or movement.

Every time the pointer moves on the required part of the page, the mousemove executes and operates the code. The mousemove is one of the important mouse events like mouseup, mouseout, click, mousedown, and other work with the MouseEvent interface.

Syntax

The following syntax uses the "mousemove" function to show the mouse movement event.

The following syntax shows the mouse movement event with the "mousemove" function using the addEventListener event.

The following syntax uses mousemove event with javascript object and function.

Support browsers

The mouse movement event function works through many browsers. The following browsers are supported by the "mousemove" and "onmousemove" functions.

  • Chrome
  • Edge
  • Firefox
  • Opera
  • Safari
  • IE

Examples

The mousemove events work with different methods, functions, and events using JavaScript tags. We can apply any functionality with mouse movement on the html tags. We can use the mouse event with the objects, windows and methods.

Example 1: the basic mouse movement event with the html tag and JavaScript function. Here we can use the mousemove function on the div tag with the handler name. The handler name uses in the JavaScript tag to operate the functionality.

Output

The following output displays the web page after the mousemove event function.

The mousemove Event in JavaScript

Example 2: the basic mouse movement event with the html tag and JavaScript function. Here we can use the mousemove function on the div tag with the handler name. The handler name uses in the JavaScript tag to operate the functionality.

Output

The following output displays the web page after the mousemove event function.

The mousemove Event in JavaScript

Example 3: The mouse movement event with the html tag and JavaScript function. Here we can use the mousemove function on the body tag with the handler name.

Output

The following output displays the web page after the mousemove event function.

The mousemove Event in JavaScript

Conclusion

The mousemove event works when we move the mouse on the web page, html tag or container of the page. We can use the mouse event on the web application to require mouse functionality per movement. It is easy to user and developer to work with the laptop, desktop and other mouse applications.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA