Jquery 在单击按钮时呈现字段的副本
我有一个字段,我想在点击按钮时乘以它。我甚至不知道从哪里开始 到目前为止我唯一的代码。fieldDef是最初由wtforms呈现的字段定义:Jquery 在单击按钮时呈现字段的副本,jquery,flask-wtforms,Jquery,Flask Wtforms,我有一个字段,我想在点击按钮时乘以它。我甚至不知道从哪里开始 到目前为止我唯一的代码。fieldDef是最初由wtforms呈现的字段定义: this.fieldDef = params.fieldDef var that = $('#' + this.fieldDef["name"]); this.init = function() { that.after('<input id="addBtn" type="button" value="Add
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()
this.fieldDef=params.fieldDef
var that=$(“#”+this.fieldDef[“name”]);
this.init=函数(){
在('')之后
$(“#addBtn”)。单击(函数(){
//这个.fieldDef.render()??
})
}
this.init()
你能给我指一些有想法的资源吗?你能用例子再解释一下你的想法吗 据我所知,在我看来,克隆人正是你所需要的。 看看这个:
这正是我需要的!非常感谢。
// 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" ) ) );