onfocusin 事件在 JavaScript 中有什么用?


当一个元素获得焦点时,onfocusin 事件会触发。你可以尝试运行以下代码来了解如何用 JavaScript 实现onfocusin 事件 -

例子

<!DOCTYPE html>
<html>
   <body>
      <p>Write below:</p>
      <input type="text" onfocusin="newFunc(this)">
      <script>
         function newFunc(x) {
            x.style.background = "blue";
         }
      </script>
   </body>
</html>

更新于: 2020 年 6 月 23 日

131 次浏览

开启你的职业生涯

通过完成课程获取认证

开始
广告