Below is a textarea. Now, when you type something in the textarea, a JS script would check if the particular word, which you want to check, is typed in it.
Enter the word that you want to check in the first box.
Here's the script.
<body> <p>Word to check... <input type="text" value="the" id="tb" /></p> <p> <textarea onkeyup='findWord(this)' id='ta' rows="3" cols="40" placeholder="start typing here..."></textarea> </p> <p id="result"></p> </body> <script> let findWord = (el) => { let wrd_2_find = document.getElementById('tb').value.toLowerCase(); let ta = document.getElementById(el.id).value.toLowerCase(); document.getElementById('result').innerHTML = ta.includes(wrd_2_find) == true ? 'word exits' : 'no match'; } </script>
You can use the includes() method in many other ways, like check if a particular word is inside a <div> element or use the method to check if a certain element or value is inside an array.
Happy coding. 😀