It's better if you can share your HTML code snippet, then it is easier to construct js code, anyway here is the illustration made for you :
Html(let say all of these created by loop process)
// put class name on button for references
// 1st group
<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="b"><button class="removeBtn">Remove</button>
// 2nd group
// this code wrapped inside parent container
<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>
jQuery
// for first group of textbox
$(document).on('click', '.removeBtn', function() {
// Must be noted that, textbox must be aside with button
// that why we asked for HTML snippet
$(this).prev().remove().end().remove();
// or $(this).prev('.a').remove().end().remove();
});
// for second group of textbox
$(document).on('click', '.removeBtn2', function () {
// just remove it parents
$(this).closest('.container').remove();
});
DEMO