滑鼠指標移出 HTML 元素時執行指令碼?


滑鼠指標移出元素時,onmouseout 屬性被觸發。你可以嘗試以下程式碼來實現 onmouseout 屬性 -

示例

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

更新時間:03-Mar-2020

100 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始
廣告