编辑下面的代码:【加编码】
<html> <head> <script> function setStyle(x) { document.getElementById(x).style.background="yellow"; } </script> </head> <body> <p>当输入域获得焦点时setStyle函数被触发。该函数改变输入域的背景色。</p> 第一个名字: <input type="text" id="fname" onfocus="setStyle(this.id)"><br> 最后一个名字: <input type="text" id="lname" onfocus="setStyle(this.id)"> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂