Skip to content
Related Articles

Related Articles

HTML | DOM MouseEvent

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 21 Aug, 2019

Events that occur when the mouse interacts with the HTML document falls under the category of MouseEvent property.

Event Types:

  • onclick: The event occurs when the user clicks on an element.
  • onmousedown: The event occurs when the button pressed over an element.
  • onmouseenter: The event occurs when the pointer is moved onto an element.
  • onmouseout: The event occurs when a user moves the mouse pointer out of an element, or out of one of its children.
  • onmouseup: The event occurs when a user releases a mouse button over an element.
  • oncontextmenu: This event occurs on right-click on an element.
  • ondblclick: This event occurs on double-click on an element.
  • onmouseleave: When pointer is moved out of an element.
  • onmousemove: This event occurs while pointer move over element.
  • onmouseover: This event occurs when the pointer move over an element, or its children.


  • onmouseup property:
    <element onmouseup="ID">
  • onmousedown property:
    <element onmousedown="ID">
  • onclick property:
    <element onclick="ID">
  • oncontextmenu property:
    <element oncontextmenu="ID">
  • ondblclick property:
    <element ondblclick="ID">
  • onmouseenter property:
    <element onmouseenter="ID">
  • onmouseleave property:
    <element onmouseleave="ID">
  • onmousemove property:
    <element onmousemove="ID">
  • onmouseout property:
    <element onmouseout="ID">
  • onmouseover property:
    <element onmouseover="ID">

Example-1: Below program illustrate onmousedown and onmouseup property.

<!DOCTYPE html>
  <h3>GEEKS FOR GEEKS</h3>
    <p id="myP" onmousedown="mouseDown()" onmouseup="mouseUp()">
        . The mouseDown() function works when the mouse button 
           is pressed down over this paragraph and sets the color of the text to 'Yellow'. 
          The mouseUp() function works when the mouse button is 
            released and sets the color of the text to 'Red'.
        function onmouseDown() {
            //  using onmousedown property
            document.getElementById("myP").style.color = "yellow"; 
        function mouseUp() {
            //  using onmouseup property
            document.getElementById("myP").style.color = "red"; 




Supported Browsers:

  • Google Chrome
  • Mozilla Firefox
  • Edge
  • Opera
  • Safari

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!