Requirement: Click the row to automatically select the single button in the current row.
ASPX page:
<asp:Repeater ID="rptRecordList" runat="server"> <HeaderTemplate> <table style="width: 100%;" id="tbList"> </HeaderTemplate> <ItemTemplate> <tr class="order-item"> <td style="width: 96px;" class="item"> <span style="margin-right: 4px;"><%# Container.ItemIndex +1 %></span> <input type="radio" name="rbtn" id="rbtn1" value='<%#Eval("hx_t_watermeterid")%>' /> </td> <td style="width: 200px;" class="item"><%#Eval("name") %></td> <td style="width: 200px;" class="item"><%#Eval("accountnumber") %></td> <td class="last"><%#Eval("hx_fmetercode") %></td> </tr> </ItemTemplate> <FooterTemplate> </table></FooterTemplate> </asp:Repeater>
JS Code:
$ (Document ). ready (function () {// $ ("# tblist TR: odd "). addclass ("Alt"); even row style // $ ("# tblist TR: Even" ).css ("background-color", "White "); // odd row style $ ("# tblist TR "). hover (function () {$ (this ). addclass ('overcss ');}, function () {$ (this ). removeclass ('overcss ');}). click (function (e) {if ($ (E. srcelement | e.tar get ). ATTR ("type ")! = "Radio") {$ (this ). find (": Radio "). click (); // $ (this ). find (": Radio "). ATTR ("checked", true); problem}); $ ("# tblist input [type = 'Radio ']"). click (function () {$ (this ). parent (). parent (). addclass ('clickcss '). siblings (). removeclass ('clickcss '). end ();});});
CSS style:
. Altcss {Background: # FFF;/* This line adds the background color to all tr */}. overcss {background-color: # fef2e8;/* # eef2fb: the background color of the highlighted line with the mouse */}. clickcss {background-color: # a7cdf0;}/* 3366ff */
Click the row to automatically select the single button in the current row.