代码示例:(标识:event_onfocusin_html)
<!DOCTYPE html>
<html>
<body>

<p>本例演示如何将 "onfocusin" 事件分配给 input 元素。</p>

请输入您的姓名:<input type="text" id="fname" onfocusin="myFunction()">

<p><b>注释:</b>Firefox 不支持 onfocusin 事件。</p>

<script>
function myFunction() {
  document.getElementById("fname").style.backgroundColor = "red";
}
</script>

</body>
</html>
运行结果: