0

サイトでリンクボタンを使用しました。「削除」ボタンの起動時に無効にする必要があります。「追加」ボタンをクリックすると有効になります。しかし、私は達成できません。どんな間違いをしたかわかりません。どなたか訂正してください。

enter code here

if ($('.' + inputContainerCss).length < 3) {
    //    if ($('.' + inputContainerCss).length < 2) {
    $('#' + btnDelId).attr('disabled', 'disabled');
}

  $('#' + btnAddId).click(function () {
    var num = $('.' + inputContainerCss).length; // how many "duplicatable" input fields we currently have
    var newNum = new Number(num + 1);   // the numeric ID of the new input field being added

    // create the new element via clone(), and manipulate it's ID using newNum value
    var newElem = $('#' + inputContainerIdPrefix + num).clone().attr('id', inputContainerIdPrefix + newNum);

    // manipulate the name/id values of the input inside the new element
    //newElem.children(':first').attr('id', firstChildInputIdPrefix + newNum).attr('name', firstChildInputIdPrefix + newNum);


    newElem.children().each(function () {
        var idPrefix = $(this).attr('id').substring(0, $(this).attr('id').length - 1);
        var namePrefix = $(this).attr('name').substring(0, $(this).attr('name').length - 1);
        $(this).attr('id', idPrefix + newNum).attr('name', namePrefix + newNum);
    })

    // insert the new element after the last "duplicatable" input field
    $('#' + inputContainerIdPrefix + num).after(newElem);

    // enable the "remove" button
    $('#' + btnDelId).attr('disabled', '');
4

1 に答える 1

1

これはコーディングの問題ではありません。このためにいくつかの jquery ファイルを追加する必要があります。

リンクをクリックしてダウンロードするだけです。

于 2013-03-13T11:36:15.763 に答える