日期:2014-05-17  浏览次数:20655 次

帮忙写个JQ:文本框获得焦点时改变背景颜色
要求:文本框获得焦点时改变背景颜色,获得焦点时,背景色为“#FFFF66”;失去焦点时,背景色为“#FFFFFF”。




源代码:

<html>
<head>

</head>

<body>
<form name="form1" method="post" action="">
<table align="center" width="337" height="204" border="0">
  <tr>
    <td width="108">用户名:</td>
    <td width="213"><input type="text" id="Text1"></td>
  </tr>
  <tr>
    <td>密码:</td>
    <td><input type="text" id="Text2"></td>
  </tr>
  <tr>
    <td>真实姓名:</td>
    <td><input type="text" id="Text3"></td>
  </tr>
  <tr>
    <td>性别:</td>
    <td><input type="text" id="Text4"></td>
  </tr>
  <tr>
    <td>邮箱:</td>
    <td><input type="text" id="Text5"></td>
  </tr>
</table>
</form>
</body></html>
HTML

------解决方案--------------------
$(function(){
              $(":input").focus(function(){
                     $(this).css('background','#FFFF66');
              }).blur(function(){
                     $(this).css('background','#FFFFFF');
              });
       });

这个只要网上一搜索就有的了
------解决方案--------------------
挺简单的啊,你百度看看获得焦点的函数,然后直接用js写就行了。。。