I want to delete a div element that contains 3 input tags. The function named addTextbox
adds a div element using 'before'. Now I need to erase this newly created div element. Any solution?
<div id="box" style="margin-bottom: 10px; display: inline-block; width: 100%";>
<input type="hidden" name="nurse_id[]" value="" />
<input type="text" class="form-control" name="nameAdd[]" placeholder="" style="width:30%;float:left;margin-right:8px";>
<input type="text" class="form-control" name="phoneNumberAdd[]" placeholder="" style="width:59%;float:left";>
<input type="button" class="btn btn-alt-primary" value="+" onclick="addTextbox()" style="width:9%;float:right;font-weight:bold;">
</div>
<script>
let addTextbox = function() {
let newP = "<div style='margin-bottom: 10px; display: inline-block; width:100%;'><input type='text' class='form-control' name='nameAdd[]' placeholder='' style='width:30%;float:left;margin-right:8px';> " +
"<input type='text' class='form-control' name='phoneNumberAdd[]' placeholder='' style='width:59%;float:left';> " +
"<input type='button' class='btn btn-alt-danger' value='-' onclick='removeNewData()' style='width:9%;float:right;font-weight:bold;'></div>";
$('#box').before(newP);
}
</script>