鼠标点文本框里是黄色,鼠标离开是其他颜色,或者变回原来的颜色,onfocus,onblur,js
- <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"
- onfocus="setStyle(this.id)" onblur="setStyle2(this.id)" id="fname" />
- <br />
- Last name: <input type="text"
- onfocus="setStyle(this.id)" onblur="setStyle3(this.id)" id="lname" />
- </body>
- </html>