JSFiddle - React, Tailwind, and code Playground
HTML
Введите <i>что, мамонт, сверло</i> или т.п.<br>
Поиск <input class='searchText' type="text"/>
<input class="searchButton" type="button" value="найти"/>
<input class="hardStyle" type="checkbox"/> Hard Style?
<table id="info">
<tr>
<td class="info-title">Какахи мамонта</td>
<td class="info-content">Нужны чтобы замазывать трещины.</td>
</tr>
<tr>
<td class="info-title">Сверло</td>
<td class="info-content">Сверлим дыры с любовью.</td>
</tr>
<tr>
<td class="info-title">Лечим рак в домашних условиях под наркотой</td>
<td class="info-content">Я склоняюсь к тому, что, отрезав себе веко, вы вновь обретете здоровье, относительно рака. Во всяком случае я так думаю.</td>
</tr>
</table>
CSS
body{
font-family:arial;
font-size:13px;
}
#info tr{
display: none;
}
.found{
display: table-row !important;
}
.info-title{
padding:5px;
border:1px solid #ddd;
border-radius:3px;
background: #eee;
}
JavaScript
$('.searchText').keyup(function(){
$('#info tr').removeClass('found');
myExtraSearch($('.hardStyle').prop('checked'));
});
function myExtraSearch(hard){
var searchWords = $('.searchText').val().split(' ');
$('#info tr').each(function(){
for(var i = 0, l = searchWords.length; i < l; i++){
if($(this).text().indexOf(searchWords[i]) != -1){
$(this).addClass('found');
}else{
if(hard){
$(this).removeClass('found');
return;
}
}
}
});
}