Execute a script when a mouse pointer moves out of an element in HTML?


When the mouse pointer moves out of an element, the onmouseout attribute triggers. You can try the following code to implement onmouseout attribute −

Example

<!DOCTYPE html>
<html>
   <body>
      <h3 id = "myid" onmouseout = "mouseOut()">
         This is demo heading.
      </h3>
      <p>Click above and then release.</p>

      <script>
         function mouseOut() {
            document.getElementById("myid").style.color = "red";
         }

      </script>
   </body>
</html>

Updated on: 03-Mar-2020

76 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements