FiltersLesson 152Free preview
Filter Table
This lesson is part of How To · All levels
Summary
This lesson discusses the filtering of table rows based on keywords entered. Each line is checked, usually by combining text from the entire cell and then searching for keywords in it. The unmatched lines are hidden, while the table header remains visible so that the context of the column does not disappear.
Key points
- Iteration of the data line in the tbody, not the header line in the thead
- Combine textContent with multiple cells or check each cell for a broader search
- Use includes() on lowercase text to make the search flexible
- Hide the line with display: none and set the state when the result is empty
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.