Amit Dhamu

Software Engineer

Filter Table Results

The function below will allow you to use a text input to filter the results of a table with live updating of the table rows.


<!-- Your Table -->
<table class="default-table">
            <td>John Smith</td>
            <td>Mary Jane</td>
            <td>Steve Jackson</td>

<!-- Filter Text Input -->
<input id="filter-input" type="text" placeholder="Filter Table Here"/>

Function Setup and Execution

function filterTable(search, table) {
    $(table + " tr:hidden").show();

    $.each(search, function() {
        $(table + " tr:visible .indexColumn:not(:contains('" + this + "'))").parent().hide();

$(document).ready(function() {
    $("table tr:has(td)").each(function() {
        var t = $(this).text().toLowerCase();
        $("<td class='indexColumn'></td>").hide().text(t).appendTo(this);

    $("#filter-input").keyup(function() {
        var search_term = $(this).val().toLowerCase().split(" ");
        filterTable(search_term, ".default-table");

 filter / keyword / live / search

Remove Value From ArrayCSS3 Transitions

Show Comments

Made with by Amit Dhamu.
© MMXX. All rights reserved.