<!DOCTYPE html>
<html>
<body>
<p>This example uses the addEventListener() method to attach a "focusin" event to an input element.</p>
Enter your name: <input type="text" id="fname">
<p><strong>Note:</strong> Firefox does not support the focusin event.</p>
<script>
document.getElementById("fname").addEventListener("focusin", myFunction);
function myFunction() {
document.getElementById("fname").style.backgroundColor = "red";
}
</script>
</body>
</html>