Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML | DOM MouseEvent

Improve Article
Save Article
  • Last Updated : 11 Jul, 2022
Improve Article
Save Article

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 1
  • Mozilla Firefox 1
  • Internet Explorer 9
  • Edge 12
  • Opera 10.6
  • Safari 1

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!