JSFiddle - React, Tailwind, and code Playground
HTML
<input id="name" type="text" value="to remove " />
<textarea id="result" type="text">My text in which I want to remove specific words.</textarea>
<button id="myButton">click</button>
CSS
input, textarea {
display: block;
width: 300px;
}
textarea {
height: 100px;
}
JavaScript
// to execute code when the page is entierly loaded
$(document).ready(function(){
// click event on the button
$('#myButton').click(function(){
// get the content of the #result textarea
val = $('#result').val();
// remove all occurence of content of #name in #result
$('#result').val(val.replace($('#name').val(), ""));
});
});