Skip to content

Instantly share code, notes, and snippets.

@mattisbusycom
Created July 28, 2015 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattisbusycom/ae31ed53e1cbf427e645 to your computer and use it in GitHub Desktop.
Save mattisbusycom/ae31ed53e1cbf427e645 to your computer and use it in GitHub Desktop.
$(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