Problem with filter function

Hi can you help me?I’m new to javascript and I’m stuck with filter. I’m trying to use the filter function to table. however I always receive an error:

“Uncaught TypeError: rowlist.filter is not a function
at HTMLButtonElement.searchBtn.onclick”

here’s the code in jsfiddler.
https://jsfiddle.net/pinun0/4s1eyjt0/25/

it supposed to show data whatever I type on search box.

Hope you can help me. Thank you!

Hi @pinun0 and welcome to the forums.

It seems to me that the problem is that you’re calling filter on a node list instead of an array. Your node list is an iterable product of querySelectorAll, however it does not contain the filter method as that exclusively belongs to arrays and not node lists.

Potentially you could convert your node list to an array and then call filter, see:

Hope that helped

3 Likes

many thanks for the solution. I’ve been stuck with this for couple of days. I’ll try it.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.