Here I have a div in HTML:
<div class="form-check form-check-inline">
<div class="input-group">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="Other" id="Other" value="Other">Other
</label>
<input type="text" class="form-control" id="unique" aria-label="Text input with radio button" disabled>
<div class="btn-group" role="group" aria-label="Basic example">
<button type="button" class="btn btn-success ml-2 border rounded-right" id="Add">Add</button>
<button type="button" class="btn btn-success border rounded" id="Remove">Remove</button>
<button type="submit" class="btn btn-primary ml-3 border rounded">Submit</button>
</div>
</div>
</div>
Next to the Radio Button "Other" is an input allow user to add more bank type as well as remove it And here 's what I came up with Jquery:
var AddButton = $('button[id=Add]');
var RemoveButton = $('button[id=Remove]');
var NewBankDiv = $('<div class="form-check form-check-inline"></div>');
var NewBankLabel = $('<label class="form-check-label"></label>');
var AddBank = $('input[id=unique]');
AddButton.click(function () {
event.preventDefault();
NewBankLabel.append(AddBank.val());
NewBankDiv.append(NewBankLabel);
NewBankDiv.show();
});
RemoveButton.click(function () {
NewBankDiv.remove();
});
It's not working.What should I change?