I have a form with additional add and remove buttons. Upon clicking these buttons, the same form row is repeated or completely removed.
<script>
function addFormElements(current) {
$(current).parent().parent().append($(current).parent().parent().html());
}
function removeFormElements(current) {
$(current).parent().parent().remove();
}
</script>
<div class="container">
<div class="row justify-content-center align-items-center">
<div class="col-10 col-md-10 col-lg-8">
<form>
<div class="form-row" style="padding-top: 50px;" id="someId">
<div class="form-group col-md-4">
<select class="selectpicker form-control single-select" placeholder="Select an Option..." required>
<option></option>
<option>Mustard</option>
<option>Ketchup</option>
<option>Barbecue</option>
</select>
</div>
<div class="form-group col-md-6">
<input type="password" class="form-control" placeholder="">
</div>
<div class="form-group col-md-1">
<button type="button" class="btn btn-success" onclick="addFormElements(this)">+</button>
</div>
<div class="form-group col-md-1">
<button type="button" class="btn btn-danger" onclick="removeFormElements(this)">-</button>
</div>
</div>
<div class="form-row" style="padding-top: 50px;">
<button type="button" class="btn btn-primary">
Submit
</button>
</div>
</form>
</div>
</div>
</div>
You can check out the demo for the same here at JSFiddle
Problem 1: Adding rows
When, I click on the + button for the first time, it adds one row.

The above becomes this:
However, if I add click on the + button one more time, then 2 rows are added. After that 4 rows are added and so on.
Problem 2: Deleting rows
Similarly, on clicking the - button, the entire row is deleted. It should ideally only the current row.
I think I am missing something pretty basic here (about figuring out paths), but am not able to get it running even after multiple attempts. Can someone please have a look.

