Jquery clone输入并删除克隆的值

时间:2021-06-17 20:27:45

What I'm trying to archive is cloning my "box" and have a clone one without the values. So the inputs should be empty. I've got this fiddle, with only the function and html. Hope is clear and you guys can help me.

我正在尝试存档的是克隆我的“盒子”并拥有一个没有值的克隆。所以输入应该是空的。我有这个小提琴,只有功能和HTML。希望很清楚,你们可以帮助我。

http://jsfiddle.net/XeELs/117/

addAddress: function() {
    var cloneCount = 0;
    $copy = $("#scroll .first").first().clone().attr("id", "to-add-first_Clone" + cloneCount).addClass('cloned'); //add a new class cloned to the cloned outerDivs
    $(".clone", "#to-add-first_Clone" + cloneCount).attr("id", "clone_Clone" + cloneCount);
    cloneCount++;
    //check breakpoints
    var $last_bp = $('#scroll .wrap .breakpoint').last();
    var $first = $(".first", $last_bp).length;
    if ($first > 2) {
        //move this into a new breakpoint
        $('#scroll .wrap').append('<div class="breakpoint"/>');
        $last_bp = $('#scroll .wrap .breakpoint').last();
    }
    $last_bp.append($copy);
    this.drawNavigation();
},

1 个解决方案

#1


6  

I think this is the gist of what you are trying to do.

我认为这是你要做的事情的要点。

http://jsfiddle.net/XeELs/132/

The newly cloned box will have empty input values. The delete address links show up intelligently and I added the logic to create new "unique" ids.

新克隆的框将具有空输入值。删除地址链接显示智能,我添加了逻辑来创建新的“唯一”ID。

#1


6  

I think this is the gist of what you are trying to do.

我认为这是你要做的事情的要点。

http://jsfiddle.net/XeELs/132/

The newly cloned box will have empty input values. The delete address links show up intelligently and I added the logic to create new "unique" ids.

新克隆的框将具有空输入值。删除地址链接显示智能,我添加了逻辑来创建新的“唯一”ID。