Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Javascript

การใช้เหตุการณ์ onfocusout ใน JavaScript คืออะไร?


เหตุการณ์ onfocusin จะทริกเกอร์เมื่อองค์ประกอบสูญเสียการโฟกัส คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อเรียนรู้วิธีใช้งาน onfocusout เหตุการณ์ใน JavaScript

ตัวอย่าง

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