//希望这对你有用 //把这段代码放在你的HTML页面中
<div id="form-content">
<div id="cloned-content">
<input type="file" class = "focus_image" name="focus_image[]" >
</div>
</div>
<a style="cursor: pointer" id="makeclone"> makeclone </a>
// 此代码将克隆 div cloned-cotent 中的所有字段
jQuery(文档).ready(函数() {
var cloneCounter = 1;
function makeClones() {
// clone the div
var clone = $("#cloned-content").clone(false);
// change all id values to a new unique value by adding "_cloneX" to the end
// where X is a number that increases each time you make a clone
$("*", clone).add(clone).each(function() {
if (this.id) {
this.id = this.id + cloneCounter;
}
if (this.name) {
this.name = this.name
}
});
++cloneCounter;
$("#form-content").append(clone);
}
$("#makeclone").click(function() {
alert("Clicked Fired");
makeClones();
});
});