forms - jQuery: clone a div and insert it after last div with sequential id -


i need insert clone of div containing form after last div same class. how can empty form fields? have following code:

<span id="add">add</span> <div id="0" class="addr">     <input type="text" name="a">     <input type="text" name="b">     <input type="text" name="c"> </div> <script>     jquery(document).ready(function($){         $('#add').on('click',function() {             var id = $(".addr:last").attr('id');             $(".addr:last").clone().attr('id', ++id).insertafter(".addr:last");         });     }); </script> 

instead of cloning div, can use html of div append this

$('#add').on('click', function () {         var id = $(".addr:last").attr('id');         var appenddiv = jquery($(".addr:last")[0].outerhtml);             appenddiv.attr('id', ++id).insertafter(".addr:last");     }); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -