jQuery无法在ina表中工作 [英] jquery is not working ina table

查看:69
本文介绍了jQuery无法在ina表中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js">
    </script>
    <script type="text/javascript">

        $(function () {

            //Column index value of price field (Column index start from 1)
            var columnIndexValue = 2;

            var checked = $('input:checkbox').click(function (e) {

                var total = 0;
                $("tr:has(:checkbox:checked) td:nth-child(" + columnIndexValue + ")").each(function () {
                    total += parseInt($(this).text());
                });

                $('#txt').val(total.toFixed());


            });

        });


    </script>
</head>
<body>
    <form id="form1"  runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3"

            GridLines="None" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px"

            CellSpacing="1" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound">
            <columns>
                <asp:TemplateField>
                    <itemtemplate>
                        <asp:CheckBox ID="Check" runat="server" />
                        <%--<input type="checkbox"  id="chk"  runat="server" />--%>
                    </itemtemplate>
                
                <asp:TemplateField HeaderText="Emp Salary">
                    <itemtemplate>
                        <%#Eval("EmpSalary") %>
                    </itemtemplate>
                
            </columns>
            <footerstyle backcolor="#C6C3C6" forecolor="Black" />
            <rowstyle backcolor="#DEDFDE" forecolor="Black" />
            <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
            <pagerstyle backcolor="#C6C3C6" forecolor="Black" horizontalalign="Right" />
            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
        
        <p id="tot">
        </p>
    </div>
    <br />
    <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Select All
     |
    <asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">Deselct All
     |
    <asp:LinkButton ID="LinkButton3" runat="server" OnClick="LinkButton3_Click">Delete
    <br />
    <asp:Label ID="lbl" runat="server">
    <asp:TextBox ID="txt" runat="server" MaxLength="50">
    <br />
    <br />
    <br />
    <table>
        <tr>
            <td id="tttt">
            </td>
        </tr>
    </table>
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="height: 26px"

        Text="Button" />
    </form>
</body>
</html>




任何人都可以帮助我,我想要在C#代码中进行相同的操作.请帮帮我.
实际上它可以正常工作,但是当我尝试将网格保持在table.it中不起作用时




can any one help me, i want the same operation in C# code. please help me.
Actually its working fine,but when i try to keep grid in a table.its not working

推荐答案

(函数(){ // 价格字段的列索引值(列索引从1开始) var columnIndexValue = 2 ; var 已选中=
(function () { //Column index value of price field (Column index start from 1) var columnIndexValue = 2; var checked =


(' 功能(e){ var total = 0 ;
('input:checkbox').click(function (e) { var total = 0;


( tr:has(:checkbox:checked)td:nth-​​child(" + columnIndexValue + )").each( parseInt (
("tr:has(:checkbox:checked) td:nth-child(" + columnIndexValue + ")").each(function () { total += parseInt(


这篇关于jQuery无法在ina表中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆