如何在 onmouseover 事件中呼叫 JavaScript 函式?


onmouseover 事件觸發器在將滑鼠移至任何元素時啟動。

示例

嘗試執行以下示例以瞭解如何從 onmouseover 事件中呼叫 JavaScript 函式

線上演示

<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>

更新於: 2020 年 1 月 8 日

2 千人次瀏覽

開啟您的 職業生涯

完成課程並獲得認證

開始
廣告
© . All rights reserved.