https://i.sstatic.net/QJALK.png
In my code, I have a function that generates bootstrap rows, each containing an input field, textarea, and a remove button.
As I call this function multiple times, I end up with several bootstrap rows. When clicking on the remove button, I change the border color of the input and textarea to indicate that they are not being considered. The remove button functions as a toggle button, adding and removing an error class assigned to the input and textarea.
Now, I want to change the text on the button from 'Remove' to 'Add'. Clicking on the 'Add' button should remove the style from the input and textarea, signaling that their values are now being considered.
function GetDynamicTextBox(value, tag) {
return'<div class="col-lg-4"><input class="form-control" type="text" value="'+tag+'" name="typetag" id="tags" data-role="tagsinput"/></div>'+'' +
'<div class="col-lg-6"><textarea class="form-control issuetext" name="comment" id="" cols="" rows="">'+value+'</textarea></div>'+
'<div class="col-lg-2">'+
'<input type="button" value="Remove" class="remove btn btn-default" /></div>'
}
$("body").on("click", ".remove", function () {
$(this).closest('#issue').find('.bootstrap-tagsinput').toggleClass('error')
$(this).closest('#issue').find('.issuetext').toggleClass('error')
});
<div class='row'id="issue">
<div class="col-lg-4">
<input class="form-control" type="text" value="'+tag+'" name="typetag"
id="tags" data-role="tagsinput"/></div>
<div class="col-lg-6">
<textarea class="form-control issuetext" name="comment" id="" cols=""
rows="">'+value+'</textarea></div>
<div class="col-lg-2">
<input type="button" value="Remove" class="remove btn btn-default" /></div>
</div>