JavaScript onmouseup Event

You are Here:

JavaScript onmouseup Event

The onmouseup event occurs when a user releases a mouse button over an element.

onmouseup Event as Attribute

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <p onmouseup="myFunction()">Click me</p> <script> function myFunction(){ document.write("You clicked"); } </script> </body> </html>

Syntax

As Attribute

<element onmouseup = "JavaScript">

As Property

object.onmouseup = function(){ // code };

Using Event Listener

object.addEventListener("mouseup" , myScript);

onmouseup Event as Property

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <p>Click anywhere</p> <script> function myFunction(){ document.write("You clicked"); } document.onmouseup = myFunction; </script> </body> </html>

Using addEventListener() Method

Note: The addEventListener() method is not supported in Internet Explorer 8 and below.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <p>Click Me</p> <script> var x = document.getElementsByTagName("p")[0]; function myFunction(){ document.write("You clicked"); } x.addEventListener("mouseup", myFunction); </script> </body> </html>

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author