鼠标点文本框里是黄色,鼠标离开是其他颜色,或者变回原来的颜色
<html>
<head>
<script type="text/javascript">
function setStyle(x)
{
document.getElementById(x).style.background="yellow"
}
function setStyle2(x)
{
document.getElementById(x).style.background="blue"
}
function setStyle3(x)
{
document.getElementById(x).style.background=""
}
</script>
</head>
<body>
First name: <input type="text"
οnfοcus="setStyle(this.id)" οnblur="setStyle2(this.id)" id="fname" />
<br />
Last name: <input type="text"
οnfοcus="setStyle(this.id)" οnblur="setStyle3(this.id)" id="lname" />
</body>
</html>