JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" class="a" value="a">
<button class="removeBtn">Remove</button>
<input type="text" class="a" value="b">
<button class="removeBtn">Remove</button>
<input type="text" class="a" value="c">
<button class="removeBtn">Remove</button>
<hr/>
<div class="container">
<input type="text" class="a" value="a" />
<button class="removeBtn2">Remove</button>
</div>
<div class="container">
<input type="text" class="a" value="b" />
<button class="removeBtn2">Remove</button>
</div>
<div class="container">
<input type="text" class="a" value="c" />
<button class="removeBtn2">Remove</button>
</div>
JavaScript
// for first group of textbox
$(document).on('click', '.removeBtn', function () {
$(this).prev().remove().end().remove();
//$(this).prev('.a').remove().end().remove();
});
// for second group of textbox
$(document).on('click', '.removeBtn2', function () {
$(this).closest('.container').remove();
});