JSFiddle - React, Tailwind, and code Playground
HTML
<div id="foo">
<span id="otherID_123">I stay.</span>
<span id="myID">I will be removed.</span>
<span id="myID_456">I will be removed.</span>
<span id="otherID_456">I stay.</span>
<span id="myID_789">I will be removed.</span>
</div>
<button>Remove</button>
JavaScript
$('button').click(function() {
$('span[id*=myID]').remove();
});