HTML DOM onmouseup Event
Last Updated :
15 Jun, 2023
The HTML DOM onmouseup event occurs on the 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:
<element onmouseup="myScript">
object.onmouseup = function(){myScript};
- In JavaScript, using the addEventListener() method:
object.addEventListener("mouseup", myScript);
Example: In this example, we will use the HTML DOM onmouseup event.
HTML
<!DOCTYPE html>
< html >
< head >
< title >
HTML DOM onmousedown Event
</ title >
</ head >
< body >
< 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 >
</ body >
</ html >
|
Output:
Supported Browsers: The browsers supported by HTML DOM onmouseup Event are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...