เหตุการณ์ onfocusin จะทริกเกอร์เมื่อองค์ประกอบได้รับการโฟกัส คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อเรียนรู้วิธีใช้งาน onfocusin เหตุการณ์ใน JavaScript -
ตัวอย่าง
<!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>