HTML DOM MouseEvent Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The MouseEvent Object handles events that occur when the mouse interacts with the HTML document. There are lots of events that interacts with the HTML document. Mouse Events: Mouse events are the action taken by the user on the web page, like clicking, hovering over, etc. Mouse Events Description onmouseup Occurs when a user releases a mouse button over an element. onmousedown Occurs when the button is pressed over an element. onclick Occurs when the user clicks on an element. oncontextmenu Occurs on right-clicking on an element ondblclick Occurs on a double-click on an element. onmouseenter Occurs when the pointer is moved onto an element. onmouseleave Occurs when the pointer is moved out of an element. onmousemove Occurs while the pointer moves over an element. onmouseout Occurs when a user moves the mouse pointer out of an element, or out of one of its children. onmouseover Occurs when the pointer moves over an element or its children. MouseEvent Properties: These properties are used to inform the defined task if that happens. Mouse Event Properties Description altKey Define whether the alt key is pressed or not. button Define the left or right-click events. clientX Return the horizontal coordinate of the mouse pointer. clientY Return the vertical coordinate of the mouse pointer. layerX Return horizontal coordinate relative to the current layer. layerY Return vertical coordinates relative to the current layer. metaKey Indicates whether or not the “meta” key was pressed. movementX Give the difference between the X coordinate of the mouse between two events. movementY Give the difference between the Y coordinate of the mouse between two events. mozInputSourc Give information about the type of device that generates the event. offsetX Returning the x-coordinate of the mouse pointer. offsetY Returning the y-coordinate of the mouse pointer. pageX Returning the horizontal coordinate of the mouse pointer. pageY Returning the vertical coordinate of the mouse pointer. relatedTarget Returning the element that is related to the element that triggered the mouse event. screenX Returning the horizontal coordinate of the mouse pointer. screenY Returning the vertical coordinate of the mouse pointer. shiftKey Define whether the shift key is pressed or not. webkitForce Find pressure applied on the touchpad or touchscreen. ctrlKey Define whether the ctrl key is pressed or not. Example: Below program illustrates onmousedown and onmouseup properties. html <h1 style="color:green">GeeksforGeeks</h1> <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'. </p> <script> function mouseDown() { // Using onmousedown property document.getElementById("myP").style.color = "yellow"; } function mouseUp() { // Using onmouseup property document.getElementById("myP").style.color = "red"; } </script> Output: HTML DOM MouseEvent Supported Browsers: Google Chrome 1 Mozilla Firefox 1 Internet Explorer 9 Edge 12 Opera 10.6 Safari 1 Comment More infoAdvertise with us Next Article HTML DOM Style outlineOffset Property K kartikgoel1999 Follow Improve Article Tags : Web Technologies HTML HTML-DOM Similar Reads HTML DOM | Style paddingLeft Property The Style paddingLeft property is used for setting or returning the left padding of an element. The padding property inserts the user desired space within the border of an element.Syntax : To get the property: object.style.paddingLeftTo set the property: object.style.left = "auto|length|%|initial|in 2 min read HTML | DOM Style paddingBottom Property The Style paddingBottom property is used for setting or returning the bottom padding of an element. The padding property inserts the user desired space within the border of an element. Syntax: To get the property:object.style.paddingBottomTo set the property value:object.style.paddingBottom = "%|len 2 min read HTML DOM Style outlineOffset Property The Style outlineOffset property in HTML DOM is used to set or return the outline offset and draw it beyond the border edge. Outlines do not take space, unlike borders. It returns a string that represents the outline-offset property of an element. Syntax: Return the outlineOffset property.object.st 1 min read HTML | DOM Style paddingTop Property The Style paddingTop property is used for setting or returning the top padding of an element. The padding property inserts the user desired space within the border of an element. Syntax : To get the property:object.style.paddingTopTo set the property:object.style.paddingTop = "%|length|initial|inher 2 min read HTML DOM Style listStyleType Property The HTML DOM Style listStyleType property is used to set or return the list-item marker type. It has default values as "disc" for <ul> and "decimal" for <ol> and returns a string that represents the type of the list. SyntaxReturns the listStyleType property.object.style.listStyleTypeSet 2 min read HTML DOM Option Object The HTML DOM Option object represents an individual <option> element within a <select>, <datalist>, or <optgroup>. It allows JavaScript to access and manipulate the properties of options, such as setting the text, value, or whether an option is selected.Properties:disabled: T 2 min read HTML | DOM Style listStylePosition Property The DOM Style listStylePosition property sets or returns the position of the list-item marker. Syntax : For set the listStylePosition property:object.style.listStylePosition = valueFor return the listStylePosition property:object.style.listStylePosition Return Value: This return a String that repres 2 min read HTML | DOM Style fontFamily Property The fontFamily property set/return a list of Font-Family names and generic-family names for text in an element. The web browser will implement the first value it recognizes. Syntax: It returns the fontFamily property.object.style.fontFamilyIt sets the fontFamily Property.object.style.fontFamily = "f 2 min read HTML | DOM Style flexShrink Property The Style flexShrink property in HTML DOM is used to set how the specific item can be shrink in relation to the remaining flexible items within the container. Syntax: It is used to return the flexShrink property.object.style.flexShrinkIt is used to set the flexShrink property.object.style.flexShrink 2 min read HTML DOM createDocumentFragment() Method The createDocumentFragment() method in HTML DOM is used to create the document fragment which is useful for changing the content of the document such as deleting, modifying, or adding a new node. This method creates the document fragment, then appends the elements of the document to the document fra 2 min read Like