Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTML | DOM onmouseup Event

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The HTML DOM onmouseup event occurs on release of a pressed button on a mouse over an element.
Related events for left-click: 
 

  • onmousedown
  • onmouseup
  • onclick

Related events for right-click: 
 

  • onmousedown
  • onmouseup
  • oncontextmenu

Supported Tags: It supports All HTML elements, EXCEPT:

  • <base>
  • <bdo>
  • <br>
  • <head>
  • <html>
  • <iframe>
  • <meta>
  • <param>
  • <script>
  • <style>
  • <title>

Syntax: 
 

  • In HTML: 
     
<element onmouseup="myScript">
  • In JavaScript: 
     
object.onmouseup = function(){myScript};
  • In JavaScript, using the addEventListener() method: 
     
object.addEventListener("mouseup", myScript);

Example: 
 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
      HTML DOM onmousedown Event
  </title>
</head>
 
<body>
    <center>
        <h1 style="color:green">
          GeeksforGeeks
      </h1>
        <h2 id="try">
          HTML DOM onmousedown Event
      </h2>
 
        <script>
            document.getElementById(
              "try").addEventListener(
              "mousedown", btnpressed);
           
            document.getElementById(
              "try").addEventListener(
              "mouseup", btnup);
 
            function btnpressed() {
                document.getElementById(
                  "try").innerHTML = "Button Pressed.";
            }
 
            function btnup() {
                document.getElementById(
                  "try").innerHTML = "Button Released.";
            }
        </script>
    </center>
</body>
 
</html>

Output: 
 

Supported Browsers: The browsers supported by HTML DOM onmouseup Event are listed below: 
 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera

 


My Personal Notes arrow_drop_up
Last Updated : 04 Aug, 2021
Like Article
Save Article
Similar Reads
Related Tutorials