且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法从DOM检索jQuery克隆的表行吗?

更新时间:2023-11-03 11:18:16

为什么要附加一个元素,然后从DOM中获取该元素以在可以对其进行附加修改之前对其进行修改?

Why would you append an element, then get that element from the DOM to modify it when you can modify it before you append it ?

我不知道您要做什么,但是也许是这样的:

I have no idea what you're trying to do, but maybe it's something like this:

$(function() {
    $('#processname').on('click', '.addRow', function() {
        var body = $(this).closest("tbody");
        var row = $(this).closest("tr");
        var newNum = $(".operation").length + 1;
        var clone = row.clone();
        clone.find('.rowNumber').html(newNum);
        body.append(clone);
    });
});​

FIDDLE