34

I want to do a live search through the table rows, using jQuery, the "live" word is the key, because I want to type the keywords in the text input, on the same site and I'd like jQuery to automaticaly sort (or remove those who doesn't match the search query) the table rows.

Here is my HTML:

<table>
    <tr><th>Unique ID</th><th>Random ID</th></tr>
    <tr><td>214215</td><td>442</td></tr>
    <tr><td>1252512</td><td>556</td></tr>
    <tr><td>2114</td><td>4666</td></tr>
    <tr><td>3245466</td><td>334</td></tr>
    <tr><td>24111</td><td>54364</td></tr>
</table>

And if I would fe. search by the Unique ID, it should show the only rows that starts from the certain number for the Unique ID. Fe. if I would type '2' in the search input box, the following rows should stay, as they begin with 2:

<table>
    <tr><th>Unique ID</th><th>Random ID</th></tr>
    <tr><td>214215</td><td>442</td></tr>
    <tr><td>2114</td><td>4666</td></tr>
    <tr><td>24111</td><td>54364</td></tr>
</table>

If I would type 24, then there should be only one row visible as it begins from the 24:

<table>
    <tr><th>Unique ID</th><th>Random ID</th></tr>
    <tr><td>24111</td><td>54364</td></tr>
</table>

If you guys could give me some tips on how to do something like this I would appreciate it so much.

Thank you.

Sapp
  • 624
  • 2
  • 7
  • 13

21 Answers21

67

I'm not sure how efficient this is but this works:

$("#search").on("keyup", function() {
    var value = $(this).val();

    $("table tr").each(function(index) {
        if (index != 0) {

            $row = $(this);

            var id = $row.find("td:first").text();

            if (id.indexOf(value) != 0) {
                $(this).hide();
            }
            else {
                $(this).show();
            }
        }
    });
});​

DEMO - Live search on table


I did add some simplistic highlighting logic which you or future users might find handy.

One of the ways to add some basic highlighting is to wrap em tags around the matched text and using CSS apply a yellow background to the matched text i.e: (em{ background-color: yellow }), similar to this:

// removes highlighting by replacing each em tag within the specified elements with it's content
function removeHighlighting(highlightedElements){
    highlightedElements.each(function(){
        var element = $(this);
        element.replaceWith(element.html());
    })
}

// add highlighting by wrapping the matched text into an em tag, replacing the current elements, html value with it
function addHighlighting(element, textToHighlight){
    var text = element.text();
    var highlightedText = '<em>' + textToHighlight + '</em>';
    var newText = text.replace(textToHighlight, highlightedText);
    
    element.html(newText);
}

$("#search").on("keyup", function() {
    var value = $(this).val();
    
    // remove all highlighted text passing all em tags
    removeHighlighting($("table tr em"));

    $("table tr").each(function(index) {
        if (index !== 0) {
            $row = $(this);
            
            var $tdElement = $row.find("td:first");
            var id = $tdElement.text();
            var matchedIndex = id.indexOf(value);
            
            if (matchedIndex != 0) {
                $row.hide();
            }
            else {
                //highlight matching text, passing element and matched text
                addHighlighting($tdElement, value);
                $row.show();
            }
        }
    });
});

Demo - applying some simple highlighting


Community
  • 1
  • 1
Nope
  • 22,147
  • 7
  • 47
  • 72
  • Btw. could you also tell me, if thats possible to do the same for the `Random ID` search? the `:first` selector wouldnt work in this case. – Sapp Sep 15 '12 at 00:05
  • You mean if the enter value matches either column? – Nope Sep 15 '12 at 00:13
  • Nevermind, I just set the unique classes to each columns and now its okay. Have you got any idea on how to highlight typed text? – Sapp Sep 15 '12 at 00:23
  • I wouldn't know of the top of my head but after some googling I came across this: http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html which was also referenced in this post here: http://stackoverflow.com/questions/119441/highlight-a-word-with-jquery – Nope Sep 15 '12 at 00:36
  • Yea, I found those too but got some problems with the element to highlight... :/ – Sapp Sep 15 '12 at 00:46
  • @Sapp: Same here. I wasn't able to get it to work myself. Maybe you can ask this in a new question, giving your findings of that SO post and the plugin and demonstrate that you can't get it working. Otherwise peeps will think it is a duplicate of that SO post. – Nope Sep 15 '12 at 00:51
  • @Sapp: I know it has been a while but I added an example of a basic highlighting technique one can adapt into a more dynamic setting as well. – Nope May 22 '14 at 12:33
  • 2
    Thanks a lot man, it is great code. Works fine for me, except "index !== 0" was making my first tr row appear all the time no matter what is search result (i guess reason is i had tbody as well), and i fixed it by changing it to "index !== -1". And maybe it is late already, but changin your higlighted text to "var highlightedText = '' + textToHighlight + '';" will add background yellow color, if it didn't work for you. – Elnoor May 05 '16 at 16:55
  • https://stackoverflow.com/a/22085006/4425004 `sttr1.search(str2);` gives the result any possible pattern match found across the searched values. – Pranesh Janarthanan Apr 16 '19 at 09:39
32

Here's a version that searches both columns.

$("#search").keyup(function () {
    var value = this.value.toLowerCase().trim();

    $("table tr").each(function (index) {
        if (!index) return;
        $(this).find("td").each(function () {
            var id = $(this).text().toLowerCase().trim();
            var not_found = (id.indexOf(value) == -1);
            $(this).closest('tr').toggle(!not_found);
            return not_found;
        });
    });
});

demo: http://jsfiddle.net/rFGWZ/369/

rewon
  • 573
  • 5
  • 10
  • This works beautifully! I have it working as a live search feature for good size tables with 4-8 columns - thanks! For those that need to search only specific columns in their tables you can add to the `.find("td")` and make it something like `.find("td.searchable")`. – tylerl Oct 10 '14 at 15:07
  • i think this is more useful since you are not looking only in one column but the whole row :) – Ryan Monreal Feb 05 '18 at 05:19
  • In this answer, we can search any column in the table. I need this one.thanks – user9437856 Jul 04 '18 at 02:03
17

François Wahl approach, but a bit shorter:

$("#search").keyup(function() {
    var value = this.value;

    $("table").find("tr").each(function(index) {
        if (!index) return;
        var id = $(this).find("td").first().text();
        $(this).toggle(id.indexOf(value) !== -1);
    });
});

http://jsfiddle.net/ARTsinn/CgFd9/

Community
  • 1
  • 1
yckart
  • 32,460
  • 9
  • 122
  • 129
  • 1
    @François Wahl: Yeeh! Have forgotten the `:first`. Was added now! – yckart Sep 15 '12 at 00:16
  • 1
    Using the ternary operator `? ... :` to execute functions is not what it is intended for though. The operator is intended for assignments in which each expression is a simple statement without side effects. Calling functions is a side-effect. Open your fiddle and click the `JSLint` button to validate your code and you will also see `Problem at line 7 character 69: Expected an assignment or function call and instead saw an expression.` See documentation for more details http://msdn.microsoft.com/en-us/library/be21c7hw(v=vs.94).aspx Languages like C# for example will not let you compile this. – Nope Sep 15 '12 at 00:48
  • 1
    @FrançoisWahl: Wow, I didn't know that, thanks... Really helpful! But, by the way, what are the 'side effects'? I think every browser understand that Conditional Operator (?), or not? – yckart Sep 15 '12 at 00:56
  • 2
    A side-effect is anything which changes state. When you use a ternary operator to assign a value the values you assign should be simple statements. If you make a method call, the problem is that you have no idea what the method does or what other methods it may call. Say for example you calling `$(this).hide`. That method call has a side-effect as it changes state on the specified element, which is not something you want to happen when using an assignment call. This post here explains it quite well: http://programmers.stackexchange.com/questions/40297/what-is-a-side-effect – Nope Sep 15 '12 at 01:18
  • Hrm... Ok, I have to agree! Thanks, you're a ducky :-* – yckart Sep 15 '12 at 01:27
  • @FrançoisWahl I removed the ternary operator. Better for your thoughts now? – yckart Apr 09 '13 at 13:50
  • 1
    Kudos on not engaging Sizzle by using jQuery's functions instead of CSS selectors. This version is also magnitudes faster on a small scale. (Paul Irish) – Michael J. Calkins Jun 28 '13 at 01:58
6

Here is the pure Javascript version of it with LIVE search for ALL COLUMNS :

function search_table(){
  // Declare variables 
  var input, filter, table, tr, td, i;
  input = document.getElementById("search_field_input");
  filter = input.value.toUpperCase();
  table = document.getElementById("table_id");
  tr = table.getElementsByTagName("tr");

  // Loop through all table rows, and hide those who don't match the search query
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td") ; 
    for(j=0 ; j<td.length ; j++)
    {
      let tdata = td[j] ;
      if (tdata) {
        if (tdata.innerHTML.toUpperCase().indexOf(filter) > -1) {
          tr[i].style.display = "";
          break ; 
        } else {
          tr[i].style.display = "none";
        }
      } 
    }
  }
}
Natesh bhat
  • 12,274
  • 10
  • 84
  • 125
4

I took yckart's answer and:

  • spaced it out for readability
  • case insensitive search
  • there was a bug in the comparison that was fixed by adding .trim()

(If you put your scripts at the bottom of your page below the jQuery include you shouldn't need document ready)

jQuery:

 <script>
    $(".card-table-search").keyup(function() {
        var value = this.value.toLowerCase().trim();

        $(".card-table").find("tr").each(function(index) {
            var id = $(this).find("td").first().text().toLowerCase().trim();
            $(this).toggle(id.indexOf(value) !== -1);
        });
    });
 </script>

If you want to extend this have it iterate over each 'td' and do this comparison.

Michael J. Calkins
  • 32,082
  • 15
  • 62
  • 91
4

Old question but i find out how to do it faster. For my example: i have about 10k data in my table so i need some fast search machine.

Here is what i did:

$('input[name="search"]').on('keyup', function() {

        var input, filter, tr, td, i;

        input  = $(this);
        filter = input.val().toUpperCase();
        tr     = $("table tr");

        for (i = 0; i < tr.length; i++) {
            td = tr[i].getElementsByTagName("td")[0]; // <-- change number if you want other column to search
            if (td) {
                if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
                    tr[i].style.display = "";
                } else {
                    tr[i].style.display = "none";
                }
            }
        }
    })

Hope it helps somebody.

Kafus
  • 101
  • 10
2

Below JS function you can use to filter the row based on some specified columns see searchColumn array. It is taken from w3 school and little bit customised to search and filter on the given list of column.

HTML Structure

<input style="float: right" type="text" id="myInput" onkeyup="myFunction()" placeholder="Search" title="Type in a name">

     <table id ="myTable">
       <thead class="head">
        <tr>
        <th>COL 1</th>
        <th>CoL 2</th>
        <th>COL 3</th>
        <th>COL 4</th>
        <th>COL 5</th>
        <th>COL 6</th>      
        </tr>
    </thead>    
  <tbody>

    <tr>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
     </tr>

    </tbody>
</tbody>

  function myFunction() {
    var input, filter, table, tr, td, i;
    input = document.getElementById("myInput");
    filter = input.value.toUpperCase();
    table = document.getElementById("myTable");
    tr = table.getElementsByTagName("tr");

     var searchColumn=[0,1,3,4]

    for (i = 0; i < tr.length; i++) {

      if($(tr[i]).parent().attr('class')=='head')
        {
            continue;
         }

    var found = false;
      for(var k=0;k<searchColumn.length;k++){

        td = tr[i].getElementsByTagName("td")[searchColumn[k]];

        if (td) {
          if (td.innerHTML.toUpperCase().indexOf(filter) > -1 ) {
            found=true;    
          } 
        }
    }
    if(found==true)  {
        tr[i].style.display = "";
    } 
    else{
        tr[i].style.display = "none";
    }
}
}
Syed Shibli
  • 992
  • 1
  • 12
  • 15
2

This one is Best in my case

https://www.w3schools.com/jquery/jquery_filters.asp

<script>
$(document).ready(function(){
  $("#myInput").on("keyup", function() {
    var value = $(this).val().toLowerCase();
    $("#myTable tr").filter(function() {
      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
    });
  });
});
</script>
Ajay
  • 848
  • 8
  • 17
1

Here is something you can do with Ajax, PHP and JQuery. Hope this helps or gives you a start. Check the mysql query in php. It matches the pattern starting from first.

See live demo and source code here.

http://purpledesign.in/blog/to-create-a-live-search-like-google/

Create a search box, may be an input field like this.

<input type="text" id="search" autocomplete="off">

Now we need listen to whatever the user types on the text area. For this we will use the jquery live() and the keyup event. On every keyup we have a jquery function “search” that will run a php script.

Suppose we have the html like this. We have an input field and a list to display the results.

 <div class="icon"></div>
 <input type="text" id="search" autocomplete="off">
 <ul id="results"></ul>

We have a Jquery script that will listen to the keyup event on the input field and if it is not empty it will invoke the search() function. The search() function will run the php script and display the result on the same page using AJAX.

Here is the JQuery.

$(document).ready(function() {  

    // Icon Click Focus
    $('div.icon').click(function(){
        $('input#search').focus();
    });

    //Listen for the event
    $("input#search").live("keyup", function(e) {
    // Set Timeout
    clearTimeout($.data(this, 'timer'));

    // Set Search String
    var search_string = $(this).val();

    // Do Search
    if (search_string == '') {
        $("ul#results").fadeOut();
        $('h4#results-text').fadeOut();
    }else{
        $("ul#results").fadeIn();
        $('h4#results-text').fadeIn();
        $(this).data('timer', setTimeout(search, 100));
    };
});


// Live Search
// On Search Submit and Get Results
function search() {
    var query_value = $('input#search').val();
    $('b#search-string').html(query_value);
    if(query_value !== ''){
        $.ajax({
            type: "POST",
            url: "search_st.php",
            data: { query: query_value },
            cache: false,
            success: function(html){
                $("ul#results").html(html);

            }
        });
    }return false;    
}

}); In the php, shoot a query to the mysql database. The php will return the results that will be put into the html using AJAX. Here the result is put into a html list.

Suppose there is a dummy database containing two tables animals and bird with two similar column names ‘type’ and ‘desc’.

//search.php
// Credentials
$dbhost = "localhost";
$dbname = "live";
$dbuser = "root";
$dbpass = "";

//  Connection
global $tutorial_db;

$tutorial_db = new mysqli();
$tutorial_db->connect($dbhost, $dbuser, $dbpass, $dbname);
$tutorial_db->set_charset("utf8");

//  Check Connection
if ($tutorial_db->connect_errno) {
    printf("Connect failed: %s\n", $tutorial_db->connect_error);
    exit();

$html = '';
$html .= '<li class="result">';
$html .= '<a target="_blank" href="urlString">';
$html .= '<h3>nameString</h3>';
$html .= '<h4>functionString</h4>';
$html .= '</a>';
$html .= '</li>';

$search_string = preg_replace("/[^A-Za-z0-9]/", " ", $_POST['query']);
$search_string = $tutorial_db->real_escape_string($search_string);

// Check Length More Than One Character
if (strlen($search_string) >= 1 && $search_string !== ' ') {
    // Build Query
    $query = "SELECT *
        FROM animals
        WHERE type REGEXP '^".$search_string."'
        UNION ALL SELECT *
        FROM birf
        WHERE type REGEXP '^".$search_string."'"
        ;

$result = $tutorial_db->query($query);
    while($results = $result->fetch_array()) {
        $result_array[] = $results;
    }

    // Check If We Have Results
    if (isset($result_array)) {
        foreach ($result_array as $result) {

            // Format Output Strings And Hightlight Matches
            $display_function = preg_replace("/".$search_string."/i", "<b class='highlight'>".$search_string."</b>", $result['desc']);
            $display_name = preg_replace("/".$search_string."/i", "<b class='highlight'>".$search_string."</b>", $result['type']);
        $display_url = 'https://www.google.com/search?q='.urlencode($result['type']).'&ie=utf-8&oe=utf-8';

            // Insert Name
            $output = str_replace('nameString', $display_name, $html);

            // Insert Description
            $output = str_replace('functionString', $display_function, $output);

            // Insert URL
            $output = str_replace('urlString', $display_url, $output);



            // Output
            echo($output);
        }
    }else{

        // Format No Results Output
        $output = str_replace('urlString', 'javascript:void(0);', $html);
        $output = str_replace('nameString', '<b>No Results Found.</b>', $output);
        $output = str_replace('functionString', 'Sorry :(', $output);

        // Output
        echo($output);
    }
}
ashatte
  • 5,442
  • 8
  • 39
  • 50
Raj Nandan Sharma
  • 3,694
  • 3
  • 32
  • 42
1

Using yckart's answer, I made it to search for the whole table - all td's.

$("#search").keyup(function() {
    var value = this.value;

    $("table").find("tr").each(function(index) {
        if (index === 0) return;

        var if_td_has = false; //boolean value to track if td had the entered key
        $(this).find('td').each(function () {
            if_td_has = if_td_has || $(this).text().indexOf(value) !== -1; //Check if td's text matches key and then use OR to check it for all td's
        });

        $(this).toggle(if_td_has);

    });
});
Community
  • 1
  • 1
Elnoor
  • 3,401
  • 4
  • 24
  • 39
1

If any cell in a row contains the searched phrase or word, this function shows that row otherwise hides it.

    <input type="text" class="search-table"/>  
     $(document).on("keyup",".search-table", function () {
                var value = $(this).val();
                $("table tr").each(function (index) {
                    $row = $(this);
                    $row.show();
                    if (index !== 0 && value) {
                        var found = false;
                        $row.find("td").each(function () {
                            var cell = $(this).text();
                            if (cell.indexOf(value.toLowerCase()) >= 0) {
                                found = true;
                                return;
                            } 
                        });
                        if (found === true) {
                            $row.show();
                        }
                        else {
                            $row.hide();
                        }
                    }
          });
   });
user890255
  • 458
  • 5
  • 9
1

I used the previous answers and combine them to create:

Search any columns by hide rows and highlighting

Css for highlight found texts:

em {
   background-color: yellow
}

Js:

function removeHighlighting(highlightedElements) {
   highlightedElements.each(function() {
      var element = $(this);
      element.replaceWith(element.html());
   })
}

function addHighlighting(element, textToHighlight) {
   var text = element.text();
   var highlightedText = '<em>' + textToHighlight + '</em>';
   var newText = text.replace(textToHighlight, highlightedText);

   element.html(newText);
}

$("#search").keyup(function() {
   var value = this.value.toLowerCase().trim();

   removeHighlighting($("table tr em"));

   $("table tr").each(function(index) {
      if (!index) return;
      $(this).find("td").each(function() {
         var id = $(this).text().toLowerCase().trim();
         var matchedIndex = id.indexOf(value);
         if (matchedIndex === 0) {
            addHighlighting($(this), value);
         }
         var not_found = (matchedIndex == -1);
         $(this).closest('tr').toggle(!not_found);
         return not_found;
      });
   });
});

Demo here

Behzad
  • 3,502
  • 4
  • 36
  • 63
1
<!--code for table search start--> 
<script>
    $(document).ready(function () {
        $("#myInput").on("keyup", function () {
            var value = $(this).val().toLowerCase();
            $("#myTable tr").filter(function () {
                $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
            });
        });
    });
</script><!--code for table search end-->
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
0
$("#search").on("keyup", function() {
        var value = $(this).val().toLowerCase();
        $("tbody tr").filter(function() {
            $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
        });
    });

Assumption there is a one table with a tbody. you can also search with find or if the table has an ID you can use the id

0

Hey for everyone still looking in 2020. I took some answers from here and made my own searchTable function.

function searchTable() {
 var input, filter, table, tr, td, i, txtValue;
 input = document.getElementById("myInput");
 filter = input.value.toUpperCase();
 table = document.getElementById("showTable");
 tr = table.getElementsByTagName("tr");
 th = table.getElementsByTagName("th");
 var tdarray = [];
 var txtValue = [];
 for (i = 0; i < tr.length; i++) {
   for ( j = 0; j < th.length; j++) {
     tdarray[j] = tr[i].getElementsByTagName("td")[j];
   }
   if (tdarray) {
     for (var x = 0; x < tdarray.length; x++) {
       if (typeof tdarray[x] !== "undefined") {
          txtValue[x] = tdarray[x].textContent || tdarray[x].innerText;
          if (txtValue[x].toUpperCase().indexOf(filter) > -1) {
            tr[i].style.display = "";
          } else {
            tr[i].style.display = "none";
          }
       }
     }
   }
 }
}


<input style="width: 485px;" type="text" id="myInput"  class="search-box" onkeyup="searchTable()" placeholder="Suche..">
  


<table id="showTable">
  <thead>
    <tr>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>
Leon D
  • 1
0

This is my example

<input class="form-control data-search" type="text" name="employee_quick_search" data-table=".employee-table" placeholder="Kiirotsing" value="see">

<table class="employee-table">


$("tbody tr", 'table.search-table').filter(function (index) {

//IF needed to show some rows
/*
            if (index == 0 || index == 1)
                return;
*/

            var inputValueFound = false;
//input search
            $('input,textarea,select', this).each(function(){

                if( $(this).val().toLowerCase().indexOf(value) > -1 )
                    inputValueFound = true;
            });
//text search
            $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1 || inputValueFound);
        });
user2573099
  • 63
  • 1
  • 6
0

Here you can use this JQuery code. I'm personally using this code.

$("#ticket-search").on("keyup", function() {

    var value = $(this).val().toLowerCase();

    $("#ticket-table tr").filter(function() {

      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)

    });

  });
Abdul Rehman
  • 25
  • 11
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 05 '21 at 14:47
0

I tried to use the below example. but I didn't find the first record. so tried to change a little code after my search code worked.

$("#serachname").on("keyup", function () {
     
    var value = $(this).val();

    $(".search-keyword").each(function (index) {
       
            $row = $(this);
            var id = $row.find("th").text().trim();
            if (id.indexOf(value) == -1) {
                $row.hide();
            }
            else {
                $row.show();
            }
        
    });
});

Example => https://codepen.io/hardik-solgama/pen/vYdrWMj

0

You can conduct a live search in a table. Here's an example of searching any keywork in a search box to find output in a table. 

$("#serachname").on("keyup", function () {
  var value = $(this).val();
  $(".search-keyword").each(function (index) {
    $row = $(this);
    var id = $row.find("th").text().trim();
    if (id.indexOf(value) == -1) {
      $row.hide();
    } else {
      $row.show();
    }
  });
});
<link href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="form-group mx-sm-3 mt-3">
  <input type="text" class="form-control" id="serachname" placeholder="Search ">
</div>

<table class="table mt-3">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">First</th>
      <th scope="col">Last</th>
      <th scope="col">Handle</th>
    </tr>
  </thead>
  <tbody>
    <tr class="search-keyword">
      <th scope="row">1</th>
      <th>T1</th>
      <th>P1</th>
      <th>V1</th>
    </tr>
    <tr class="search-keyword">
      <th scope="row">2</th>
      <th>T2</th>
      <th>P2</th>
      <th>V2</th>
    </tr>
    <tr class="search-keyword">
      <th scope="row">3</th>
      <th>T3</th>
      <th>P3</th> 
      <th>V3</th>
    </tr>
  </tbody>
</table>
0

code script

<script>
$(document).ready(function(){
  $("#myInput").on("keyup", function() {
    var value = $(this).val().toLowerCase();
    $("#myTable tr").filter(function() {
      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
    });
  });
});
</script>

html :

<input id="myInput" type="text" placeholder="Search..">
-1

Here's how I live search a html table:
<input type='text' onkeyup="filterTo(this.value, 'myTable')" placeholder='Search...'>
<table id='myTable'>...</table>

function filterTo(input, table) {
var tr = document.getElementById(table).getElementsByTagName('tr');
for (var i = 1; i < tr.length; i++) {
    var td = tr[i].getElementsByTagName('td');
    var hide = true;
    for (var j=0; j<td.length; j++) { 
        if (td[j].innerHTML.toUpperCase().indexOf(input.toUpperCase()) > -1) { hide=false; break } 
    }
    tr[i].style.display = hide ? 'none' : '';
} }