JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="word"><input type="button" id="replaceButton" value="remove word">
<span id="list">1,2,3</span>
JavaScript
jQuery(document).ready(function($) {
$("#replaceButton").click(function() {
// find the word
var text = $('#word').val();
// create a regex
var re = new RegExp(text, "gi");
// replace the inner html
// please note: this may cause serious problems when not used on textnodes
// see: http://stackoverflow.com/questions/298750/how-do-i-select-text-nodes-with-jquery
var replacedHTML = $('#list').html().replace(re, "");
// replace
$('#list').html(replacedHTML);
});
});