Problem hiding table row

Problem hiding table row

Hi guys,

I am new to jQuery. I have created this code loop through every td with class="name" on table. If value hasn't the string from the textbox then hide the row else show it.

Here is the code: 

$(document).ready(function () {
            $("#btnFilter").click(function () {
                $("#sortTable td.name").each(function () {
                    if ($(this).text().toLowerCase().indexOf($("#txtFilter").val().toLowerCase()) == -1) {
                        $(this).parent().hide();
                    } else {
                        $(this).parent().show();
                    }
                });
            });
        });

Thank you in advance.