JSFiddle - React, Tailwind, and code Playground

by Elvin Asadov

HTML

<input type="text" id="search" placeholder="Type to search">
<table id="table">
   <tr>
      <td>Ios</td>
      <td>White</td>
   </tr>
   <tr>
      <td>Ios</td>
      <td>Black</td>
   </tr>
   <tr>
      <td>iOs</td>
      <td>Gold</td>
   </tr>
</table>

CSS

body {padding: 20px;}
input {margin-bottom: 5px; padding: 2px 3px; width: 209px;}
td {padding: 4px; border: 1px #CCC solid; width: 100px;}

JavaScript

var $rows = $('#table tr');
$('#search').keyup(function() {
    
    var val = '^(?=.*\\b' + $.trim($(this).val()).split(/\s+/).join('\\b)(?=.*\\b') + ').*$',
        reg = RegExp(val, 'i'),
        text;
    
    $rows.show().filter(function() {
        text = $(this).text().replace(/\s+/g, ' ');
        return !reg.test(text);
    }).hide();
});