如何從 onmouseover 事件呼叫 JavaScript 函式?


當你將滑鼠移動到任何元素上時,onmouseover 事件將觸發。

示例

你可以嘗試執行以下示例來學習如何從 onmouseover 事件呼叫 JavaScript 函式

Live Demo

<html>
   <head>
      <script>
         <!--
            function over() {
               document.write ("Mouse Over");
            }
            function out() {
               document.write ("Mouse Out");
            }
         //-->
      </script>
   </head>
   <body>
      <p>Bring your mouse inside the division to see the result:</p>
      <div onmouseover="over()" onmouseout="out()">
         <h2> This is inside the division </h2>
      </div>
   </body>
</html>

更新於: 08-01-2020

2K+ 瀏覽量

開啟你的 職業生涯

完成課程,獲得認證

開始
廣告