.move在chrome和safari工作但不在FF& IE

时间:2013-02-23 08:28:45

标签: jquery internet-explorer firefox

我找到了一个jquery脚本来创建一个表,并有一个按钮可以在表的底部添加行。然后,单击每行时会有链接删除该特定行。一切都按预期在Chrome& Safari但不在FireFox或IE中。这是Jquery。

    if ($("table#data tbody tr").size() == 1) {
    $('.deleteRowButton').hide();
}

$('.deleteRowButton').live('click',function() {
    var bid = $(this).attr('id');
    var nid = bid.replace(/[^\d.]/g, "");
    var pid = $("#product" + nid).val();
    $("#productschanges").append("2:" + nid + ":" + pid + ","); 
    if ($("table#data tr").size() > 1) {
    $(this).parents('tr').first().remove();

    if ($("table#data tbody tr").size() == 1) {
        $('.deleteRowButton').hide();
    } else {
        $('.deleteRowButton').show();
    }
} else {
    $('.deleteRowButton').hide();
}
});

$(".addRowButton").click(function() {
    $("table#data tbody tr:last").clone(true).find("select").each(function() {
        $(this).attr({
            'id': function(_, id) {
                return this.id.replace(/[0-9]/g, '') + i;
            },
            'name': function(_, name) {
                return this.name.replace(/[0-9]/g, '') + i;
            },
            'value': function(_, value) {
                return '';
            }
        });
        $(this).prop('disabled', false);

    }).end().find("input").each(function() {
        $(this).attr({
            'id': function(_, id) {
                return this.id.replace(/[0-9]/g, '') + i;
            },
            'name': function(_, name) {
                return this.name.replace(/[0-9]/g, '') + i;
            },
            'value': function(_, value) {
                return '';
            }
        });

    }).end().find("button").each(function() {
        $(this).attr({
            'id': function(_, id) {
                return this.id.replace(/[0-9]/g, '') + i;
            },
        });

    }).end().appendTo("table#data tbody");
    i++;

    $('.deleteRowButton').show();
});

.deleteRowButton中的附加内容适用于所有浏览器,但未按预期删除该行。有关为什么这在两个浏览器中不起作用的任何帮助?

由于 2Pher

1 个答案:

答案 0 :(得分:0)

我查看你的源代码html。我看到许多html标签位置不正确。在标记样式之前有关闭标记而不是任何打开标记。 你应该修复这个错误。有开放标签和关闭标签有效。

相关问题