This is a jquery function wich works great to add and remove form elements. But it leaves the class "input-group col-md-12 row" behind when I remove an element.
I want to change it so that it removes that aswell when I remove an input field.
Bonus: Getting rid of the "p" tag.
Jsfiddle(missing some css, so you can only see the class that's being left behind in firebug): http://jsfiddle.net/tZPg4/8270/
Function:
$('#addScnt').on('click', function() {
$('<div style="width:104%; margin-left:-4px; margin-bottom:5px;" class="input-group col-md-12 row" style="padding:0;"><p> <input class="col-md-12" id="form-field-1" type="text" placeholder="Milestone"> <a href="#" class="remScnt">Remove</a></p></div>').appendTo(scntDiv);
i++;
return false;
});
$(document).on('click','.remScnt', function() {
if( i >= 2 ) {
$(this).parents('p').remove();
i--;
}
return false;
});
});
<div>, or just remove those classes?