0

テーブルを作成するjqueryスクリプトを見つけ、テーブルの下部に行を追加するためのボタンが1つあります。次に、クリックして特定の行を削除すると、各行にリンクが表示されます。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内の追加はすべてのブラウザーで機能しますが、行は期待どおりに削除されません。これが2つのブラウザで機能しない理由について何か助けはありますか?

ありがとう2Pher

4

1 に答える 1

0

ソースhtmlを表示します。多くの html タグが正しい位置にありません。タグ スタイルの前に、開始タグではなく終了タグがあります。このエラーを修正する必要があります。開始タグと終了タグが有効です。

于 2013-02-23T10:04:35.607 に答える