问题RT:
想问下Repeater控件的行变色怎用Jquery的方式完成~因为现在只能用javascript完成
    <script language="javascript" type="text/javascript">
    function rowIn(obj) {
        obj.style.backgroundColor = "#c2d8fb";
    }
    function rowOut(obj) {
        obj.style.backgroundColor = "#FFFFFF";
    }
    </script>
<tr align="center" id="userrow" onmouseover="rowIn(this)" onmouseout="rowOut(this)">
                        <td>
                            <%#Container.ItemIndex + 1 %>
                        </td>
                        <td>
                            <%#Eval("UserName") %>
                        </td>
                        <td>
                            <%#Eval("Password")%>
                        </td>
                        <td>
                            <%#Eval("RoleName")%>
                        </td>
                        <td>
</tr>
因为jquery里我直接用
        $(document).ready(function() {
            $("tr").mouseover(function() {
                $("tr").css("backgroundColor", "#c2d8fb");
            });
            $("tr").mouseout(function() {
                $("tr").css("backgroundColor", "#ffffff");
            })
        });
这个行都会变色....貌似不像上面一个样每经过一个行才变色~谢谢牛人指导帮忙啦~

解决方案 »

  1.   

    $(document).ready(function() {
      $("tr").mouseover(function() {
      $(this).css("backgroundColor", "#c2d8fb");
      });
      $("tr").mouseout(function() {
      $(this).css("backgroundColor", "#ffffff");
      })
      });
      

  2.   

     $("tr").css("backgroundColor", "#c2d8fb");
      $("tr").css("backgroundColor", "#ffffff");
    你每次这样设置变色就错了,$("tr")是指所有TR,所以自然所有行都同时变色。要挑出你鼠标所在行才行。 $(document).ready(function() {
    $("tr").each(function(){
    $(this).mouseover(function() {
      $(this).css("backgroundColor", "#c2d8fb");
      });
    $(this).mouseout(function() {
      $(this).css("backgroundColor", "#ffffff");
      })
    })
      });