Execute a script when a mouse button is released over an element in HTML?

HTMLWeb DevelopmentFront End Technology

When the mouse button is released over an element, the onmouseup event triggers. You can try to run the following code to implement onmouseup attribute −


<!DOCTYPE html>
      <h3 id = "myid" onmousedown = "mouseDown()" onmouseup = "mouseUp()">
         This is demo heading.
      <p>Click above and then release.</p>
         function mouseDown() {
            document.getElementById("myid").style.color = "yellow";
         function mouseUp() {
            document.getElementById("myid").style.color = "blue";
Updated on 03-Mar-2020 07:04:51