"Add & Remove Product Attributes"
Bootstrap 3.1.0 Snippet by falvarez1

<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <div class="control-group" id="fields"> <label class="control-label" for="field1">Product Attributes</label> <div class="controls"> <form role="form" autocomplete="off"> <div class="entry"> <div class="input-group col-xs-3 form-group"> <input class="form-control" name="attrLabel[]" type="text" placeholder="Product Attribute Label" /> <span class="input-group-btn"> <button class="btn btn-success btn-add" type="button"> <span class="glyphicon glyphicon-plus"></span> </button> </span> </div> <div class="input-group col-xs-3 form-group"> <textarea class="form-control" rows="5" name="attrDesc[]" placeholder="Product Attribute Description"></textarea> </div> </div> <div class="form-group"> </div> </form> <br> <small>Press <span class="glyphicon glyphicon-plus gs"></span> to add another Product Attribute</small> </div> </div> </div> <div class="row"> </div> </div>
.entry:not(:first-of-type) { margin-top: 10px; } .glyphicon { font-size: 12px; }
$(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('.form-control').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; }); });

Related: See More


Questions / Comments: