Jump to content

embirath

Members
  • Posts

    1
  • Joined

  • Last visited

embirath's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. I'm new to JQuery so bare with me if I'm saying something silly. In the JQuery tutorial on w3schools website, the examples illustrating the use of the .filter() function appears to be using the filter function as a "for loop" to step through table rows. The .filter() function isn't actually doing the filtering in the table. The filtering happens when the .toggle() function either hides or shows the row in the table. Why use a filter function instead of say the .each() function? Am I missing something? They're using a function inside the filter, like $('#myTable tr').filter(function(){...}). That function isn't returning anything (there is no "return" call inside). So the use of the filter function is solely to step through the rows? Just trying to understand it. This section is under JQuery Misc / JQuery Filtering. $(document).ready(function(){ $("#myInput").on("keyup", function() { var value = $(this).val().toLowerCase(); $("#myTable tr").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1) }); }); });
×
×
  • Create New...