1 <asp:Repeater runat="server" ID="rpt_Student"> 2 <HeaderTemplate> 3 <table> 4 <tr id="tr_<%#this.rpt_Student.Items.Count%>" onclick='Tr_Click(tr_<%#this.rpt_Student.Item.Count%>)'> 5 <td>姓名</td> 6 <td>学号</td> 7 <td>成绩</td> 8 </tr> 9 </HeaderTemplate> 10 <ItemTemplate> 11 <tr > 12 <td><%#Eval("Sname")%></td> 13 <td><%#Eval("SID")%></td> 14 <td><%#Eval("Sscore")%></td> 15 </tr> 16 </ItemTemplate> 17 <FooterTemplate> 18 </table> 19 </FooterTemplate> 20 </asp:Repeater>
jq代码
<script type="text/javascript">> function Tr_Click(id) { if ($("#" + id).attr("style") == "background:red") { $("#" + id).attr("style", "background:white"); } else { $("#" + id).attr("style", "background:red"); } } </script>