+ Reply to Thread
Results 1 to 2 of 2

Thread: How can I ensure the last form is not deleted?

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    13

    How can I ensure the last form is not deleted?

    How can I ensure that the last form is never deleted?
    Code:
    - + 
    <form>
    stuff
    </form>
    So for instance, if someone presses the '+' button 3 times, effectively, there will be 4 forms. How can I stop them from deleting the first one, i.e. so that there is always one remaining?

    Here's the jQuery for the 'minus' function:
    Code:
    $(function() {
    $('.removeCreative').click(function() {
        $('#creative').find('form:last').remove();
    });
    });
    Is it as simply as something like:
    Code:
    if ( $("#creative").length > 0 ) {
    //do something
    }

  2. #2
    You almost solved it , edit this :
    Code:
    $(function() {
    
        $('.removeCreative').click(function() {
            if($("#creative").children("form").length > 1){
                $('#creative').find('form:last').remove();
            }
        });
    });

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts