JSFiddle - React, Tailwind, and code Playground
HTML
<input class="search"><div class="btn">Search</div>
<br />
<span class="result"></span>
<div>Ion</div>
<div>Vasile</div>
<div>caca</div>
<div>mar</div>
<div>mar</div>
CSS
.succes{
color:red;
}
.btn{
display:inline;
cursor:pointer;
border:1px solid #000;
width:100px;
}
JavaScript
'use strict';
$('.btn').on('click', function(e){
e.preventDefault();
$('*').removeClass('succes');
searchKey();
});
function searchKey(){
var keyword = $('.search').val();
var place = $( "body" ).text().match(new RegExp(keyword, 'g'));
if(place.length > 0)
{
alert(1)
$('.result').html('S-au gasit <b>'+place.length+ '</b> rezultate!');
result.addClass('succes')
}
else
{
$('.result').html('Nici un rezultat pt.: '+keyword);
}
}