Click the row to automatically select the single button in the current row.

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.