24 Create a JavaScript using Mouse Event such that when mouse pointer is on button background image will be changed.

Program:

<html>



<head>

  <script>

    function clickEvent() {

      document.getElementById("img").src = "./Logo.png";

    }

    function over() {

      document.getElementById("img").src = "./submit.jpg";

    }

    function down() {

      document.getElementById("img").src = "./reset.jpg";

    }

    function dblclickEvent() {

      document.getElementById("img").src = "./reset.jpg";

    }

  </script>

</head>



<body>

  <form name="f">

    <img src="./Logo.png" width="300" id="img"  onmouseover="over()"  onmousedown="down()"><br><br>

    <input type="button" value="Click" onclick="clickEvent()"  name="b1"><br><br>

    <input type="button" value="Double Click" ondblclick="dblclickEvent()"><br><br>

  </form>

</body>



</html>


Output:

Mouse event in JavaScript

Previous
Next Post »