JSFiddle - React, Tailwind, and code Playground

by id10922606

HTML

<input type="text"/>
<div>John Resig
George Martin
Malcom John Sinclair
J. Ohn 
Sample text</div>

CSS

span{
    background : red
}

JavaScript

$("input").keyup(function(){
var mysearchword = $("input:text").val();    
var word = mysearchword;
$( "div:contains('"+word+"')" ).html(function(i,html){
var re = new RegExp(word,"g");
return html.replace(re,'<span>'+word+'</span>')
});
});