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 次浏览

开启你的 职业生涯

完成课程认证

开始
广告