• 单击行,自己主动选中当前行中的单选框button


    需求:单击行,自己主动选中当前行中的单选框button。

    aspx页面:
         <asp:Repeater ID="rptRecordList" runat="server">
                                        <HeaderTemplate>
                                            <table style=" 100%;" id="tbList">
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <tr class="order-item">
                                                <td style=" 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=" 200px;" class="item"><%#Eval("name") %></td>
                                                <td style=" 200px;" class="item"><%#Eval("accountnumber") %></td>
                                                <td class="last"><%#Eval("hx_fmetercode") %></td>
                                            </tr>
                                        </ItemTemplate>
                                        <FooterTemplate>
                                            </table></FooterTemplate>
                                    </asp:Repeater>
    js代码:
       $(document).ready(function () {
                    //$("#tbList tr:odd").addClass("alt"); 偶数行样式
                    //$("#tbList tr:even").css("background-color", "white"); //奇数行样式
                    $("#tbList tr").hover(function () { $(this).addClass('overCss'); }, function () { $(this).removeClass('overCss'); }).click(
                        function (e) {
                            if ($(e.srcElement || e.target).attr("type") != "radio") {
                                $(this).find(":radio").click(); //$(this).find(":radio").attr("checked", true);有问题
                            }
                        });
                    $("#tbList input[type='radio']").click(function () {
                        $(this).parent().parent().addClass('clickCss')
                        .siblings().removeClass('clickCss')
                        .end();
                    });
                });
    css样式:
    .altCss{
    background:#fff;  /*这行将给全部的tr加上背景色*/
    }
    .overCss{
    background-color:#FEF2E8;  /* #EEF2FB这个将是鼠标高亮行的背景色*/
    }
    .clickCss{background-color:#A7CDF0;} /*3385ff*/


  • 相关阅读:
    centos7编译安装php 遇到的问题
    linux中以.d结尾的目录
    webpack 的安装与使用
    nginx 设置反向代理
    常用git命令
    windows命令行模式打开目录
    scapy 中sniff指定的数据包并打印指定信息
    python scapy中sniffer的用法以及过滤器
    scapy构造数据包
    21天实战人工智能系列:人工智能产品经理最佳实践(1)
  • 原文地址:https://www.cnblogs.com/blfshiye/p/5386166.html
Copyright © 2020-2023  润新知