table动态添加的tr 其click事件在IE兼容模式中不执行 jquery 1.9 的live事件 和获取 first last...

本文介绍了如何使用jQuery为动态生成的表格绑定点击事件,并通过AJAX请求更新表格内容。展示了如何选择特定的表格元素并触发相关操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 http://www.css88.com/jqapi-1.9/first-of-type/index.html#p=//www.css88.com/jqapi-1.9/last-child-selector

 

---动态添加的table 的tr 给tr设定click事件 使用jquery 1.9

$(document).on("click", "#tableid tbody tr", function () {
$("#tableid tbody").find("tr").removeClass("trclass");
$(this).addClass("trclass");
var name = $(this).attr("data");
$("#txtsearch").val(name);
});
 function changetable() {
            var n = $.trim($("#txtsearch").val());
            if (n != "") {
                $.ajax({
                    type: "POST",
                    url: "../xxx/xx.aspx?action=getxx",
                    data: { "n": n },
                    dataType: "json",
                    async: false,
                    success: function (data) {
                        var varc = "";
                        $.each(data.Table, function (index, item) {
                            varc += "<tr data='" + item.id + "' ><td>" + item.id + "</td><td>" + item.name + "</td></tr>";                         
                        });
                        $("#tableid tbody").empty().append(varc);
                    }, error: function () {
                    }
                });
            }
        }

 --first(first-of-type) last(last-of-type) 

 $(document).on("click", "#file table tr td:first-of-type a", function () {
                var n1 = $(this).attr("data"); var n2 = $(this).attr("data2");
                down(n1, n2);
            });
            $(document).on("click", "#file table tr td:last-of-type a", function () {
                var n = $(this).attr("data");
                delAttach(this,n);
            });

 

转载于:https://www.cnblogs.com/jcz1206/p/4246310.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值