Sự kiện onfocusin kích hoạt khi một phần tử được lấy tiêu điểm. Bạn có thể thử chạy mã sau để tìm hiểu cách triển khai onfocusin sự kiện trong JavaScript -
Ví dụ
<!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>