我怎样才能在最后一个孩子后追加元素?

时间:2015-08-27 12:32:16

标签: jquery html

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>

但它不起作用。我做错了什么?

0 个答案:

没有答案