I
I
Ilya Bobkov2015-11-02 19:26:18
JavaScript
Ilya Bobkov, 2015-11-02 19:26:18

How to filter a table?

Hey! I need to filter the table by 2 columns : I
use the following code:

var filter = $("#filter");       // < -- это Input
filter.keyup(function(e)
{
    $('#main_table td:nth-child(1)').each(function()
    {
        if(filter.val() != $(this).text().substr(0, filter.val().length)) 
  {
            $(this).parent().hide();
        } else {
            $(this).parent().show();
        }
    });
});


Filtered by only the 1st column. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
L0k1, 2015-11-02
@L0k1

td:nth-child( 2 )?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question