Created
July 28, 2015 00:20
-
-
Save mattisbusycom/ae31ed53e1cbf427e645 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() | |
{ | |
$(document).on('click', '.btn-add', function(e) | |
{ | |
e.preventDefault(); | |
var controlForm = $('.controls form:first'), | |
currentEntry = $(this).parents('.entry:first'), | |
newEntry = $(currentEntry.clone()).appendTo(controlForm); | |
newEntry.find('input').val(''); | |
controlForm.find('.entry:not(:last) .btn-add') | |
.removeClass('btn-add').addClass('btn-remove') | |
.removeClass('btn-success').addClass('btn-danger') | |
.html('<span class="glyphicon glyphicon-minus"></span>'); | |
}).on('click', '.btn-remove', function(e) | |
{ | |
$(this).parents('.entry:first').remove(); | |
e.preventDefault(); | |
return false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment