Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="taskForm">
- <div class="form-group">
- <label class="text-left">Name</label>
- <input name="name" placeholder="Name" type="text">
- <a class="remAdd removeButton" href="javascript:;"><i class="fa fa-times"></i></a>
- <label for="livingkid1">
- <input id="livingkid1" name="livingkid" type="radio" value="1">Yes
- </label>
- <label for="livingkid2">
- <input id="livingkid2" name="livingkid" type="radio" value="0">No
- </label>
- </div>
- <!-- Clone part -->
- <div class="form-group hide" id="taskTemplate">
- <input name="name" placeholder="Name" type="text">
- <a class="remAdd removeButton" href="javascript:;"><i class="fa fa-times"></i></a>
- <label for="livingkid1">
- <input id="livingkid1" name="livingkid" type="radio" value="1">Yes
- </label>
- <label for="livingkid2">
- <input id="livingkid2" name="livingkid" type="radio" value="0">No
- </label>
- </div>
- <a class="addButton" href="#" id="addChild">Add child</a>
- </div>
- $(document).ready(function() {
- $('#taskForm')
- // Add button click handler
- .on('click', '.addButton', function() {
- var $template = $('#taskTemplate'),
- $clone = $template
- .clone(true,true)
- .removeClass('hide')
- .removeAttr('id')
- .insertBefore($template);
- $(".remAdd").toggle($(".remAdd").length > 2);
- })
- // Remove button click handler
- .on('click', '.removeButton', function() {
- var $row = $(this).closest('.form-group');
- $row.remove();
- $(".remAdd").toggle($(".remAdd").length > 2);
- });
- $(".remAdd").toggle($(".remAdd").length > 2);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement