<!DOCTYPE html>
<html>
<body>
请输入您的姓名:<input type="text" onfocusin="myFunction(this)">
<p>当输入字段获得焦点时,会触发一个更改背景颜色的函数。</p>
<script>
function myFunction(x) {
x.style.background = "yellow";
}
</script>
</body>
</html>