HTML:
<div class="uploader" id="uniform-file">
<input type="file" name="data[Tolet][images][]" class="span12 tolet_img" id="file" style="width: 100%; opacity: 0;" size="20"><span class="filename">No file selected</span><span class="action">Choose File</span>
</div>
<div class="uploader" id="uniform-file">
<input type="file" name="data[Tolet][images][]" class="span12 tolet_img" id="file" style="width: 100%; opacity: 0;" size="20"><span class="filename">No file selected</span><span class="action">Choose File</span>
</div>
JQuery的:
$(document).ready(function(){
$('.tolet_img').click(function(){
var htmlString = $('.uploader').clone(true);
$('.uploader').children().last().after(htmlString);
});
});
我希望点击一下后输出以下内容。
<div class="uploader" id="uniform-file">
<input type="file" name="data[Tolet][images][]" class="span12 tolet_img" id="file" style="width: 100%; opacity: 0;" size="20"><span class="filename">No file selected</span><span class="action">Choose File</span>
</div>
<div class="uploader" id="uniform-file">
<input type="file" name="data[Tolet][images][]" class="span12 tolet_img" id="file" style="width: 100%; opacity: 0;" size="20"><span class="filename">No file selected</span><span class="action">Choose File</span>
</div>
<div class="uploader" id="uniform-file">
<input type="file" name="data[Tolet][images][]" class="span12 tolet_img" id="file" style="width: 100%; opacity: 0;" size="20"><span class="filename">No file selected</span><span class="action">Choose File</span>
</div>
但它不起作用。我做错了什么?