在单击按钮时渲染字段的副本

rendering the copy of the field on the button click

我得到了我想在单击按钮时相乘的字段。我什至不知道从哪里开始?

到目前为止我唯一的代码。 fieldDef 是最初由 wtforms 渲染的字段定义:

    this.fieldDef = params.fieldDef
    var that = $('#' + this.fieldDef["name"]);

    this.init = function() {
       that.after('<input id="addBtn" type="button" value="Add another"/>')
       $("#addBtn").click(function(){
         //this.fieldDef.render()??
       })
     }
     this.init()

你能给我指出一些有想法的资源吗?

你能用例子多解释一下你的想法吗?

据我了解,克隆正是您所需要的。 看一下这个: https://api.jquery.com/clone/

// Original element with attached data
var $elem = $( "#elem" ).data( "arr", [ 1 ] ),
    $clone = $elem.clone( true )
      // Deep copy to prevent data sharing
      .data( "arr", $.extend( [], $elem.data( "arr" ) ) );