Clone form and increment

前端 未结 5 430
感情败类
感情败类 2020-12-03 16:21

I have a form below that I want to clone, increment the id(att1) and it\'s inputs, textareas etc and append to the attendees div. Any help much appreciated. Been wrecking my

5条回答
  •  星月不相逢
    2020-12-03 16:57

    This example might help you. example

    $(function() {
        var scntDiv = $('#p_scents');
        var i = $('#p_scents p').size() + 1;
    
        $(document).on('click','#addScnt', function() {
                $('

    Remove

    ').appendTo(scntDiv); i++; return false; }); $(document).on('click','#remScnt', function() { if( i > 2 ) { $(this).parents('p').remove(); i--; } return false; }); });

提交回复
热议问题