顺便说一下,代码是用form元素包装的。
== source ==
var source = $( '#table-wrapper' ),
clone = source.clone( true ),
count = clone.length;
<div id="table-wrapper">
<table>
<tr>
<td></td>
</tr>
</table>
<p class="pdf-add-row"><input id="pdf" type="file"/></p>
</div>
== clone ==
<div id="table-wrapper-1">
<table>
<tr>
<td></td>
</tr>
</table>
<p class="pdf-add-row"><input id="pdf-1" type="file"/></p>
</div>
答案 0 :(得分:2)
试试这段代码:
$('button').click(function () {
var source = $( '#table-wrapper' ),
clone = source.clone( true ),
count = clone.length;
clone.find('input').val('');
clone.appendTo('#result')
})
答案 1 :(得分:0)
这样做..
clone = source.clone( true ).find('input').val('')
答案 2 :(得分:0)
您可以尝试类似
的内容
$('button').click(function() {
var source = $('#table-wrapper'),
clone = source.clone(true),
count = clone.length;
//append the clone to a temp form so that it can be restted
$('<form />').append(clone)[0].reset();
clone.appendTo('#result')
})
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="table-wrapper">
<table>
<tr>
<td></td>
</tr>
</table>
<p class="pdf-add-row">
<input id="pdf-1" type="file" />
</p>
</div>
<button>Clone</button>
<div id="result"></div>
&#13;
演示:Fiddle