如何從 onmouseout 事件呼叫 JavaScript 方法?


onmouseout 事件會在您將滑鼠移出該元素時觸發。

示例

您可以嘗試執行以下示例,瞭解如何從 onmouseout 事件中呼叫 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-01-08

280 次瀏覽

開啟您的 職業生涯

完成教程認證

開始
廣告
© . All rights reserved.