JavaScript 中 onfocusout 事件的用法是什麼?


onfocusin 事件會在元素失去焦點時觸發。你可以嘗試執行以下程式碼瞭解如何在 JavaScript 中實現 onfocusout 事件。

示例

<!DOCTYPE html>
<html>
   <body>
      <p>Write below:</p>
      <p>After losing focus, the background color of input check will change.</p>
      <input type = "text" onfocusout = "newFunc(this)">
      <script>
         function newFunc(x) {
            x.style.background = "blue";
         }
      </script>
   </body>
</html>

更新於: 2020 年 5 月 22 日

222 次瀏覽

開啟你的 職業生涯

完成課程認證

開始
廣告
© . All rights reserved.