javascript 文本背影色的变化

<html>
<head>
<script type="text/javascript">
function setStyle(x)
{
document.getElementById(x).style.background="yellow";
}

function setStyle1(x)
{
document.getElementById(x).style.background="green";
}

</script>
</head>

<body>

First name: <input type="text"
onfocus="setStyle(this.id)" id="fname" onblur="setStyle1(this.id)" />
<br />
Last name: <input type="text"
onfocus="setStyle(this.id)" id="lname" onblur="setStyle1(this.id)" />

</body>
</html>

你可能感兴趣的:(JavaScript)