Need to make a search bar only search what's in a table

So I have the code to create a search bar, I have also created a basic table in html. How do I get the search bar to only search the table? I heard that you can give a class to the table and then change the data collection in the search bar to search that class, right?