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 次瀏覽

開啟你的職業生涯

透過完成課程獲取認證

開始
廣告
© . All rights reserved.