I am using target.getElementsByClassName('numerical')) to get the list of elements with classname of numerical . I want to further filter only th from the list. How can i do that?
0: th.ant-table-cell.numerical
1: th.ant-table-cell.numerical
2: td.ant-table-cell.numerical
3: td.ant-table-cell.numerical
Use querySelectorAll
target.querySelectorAll('th.numerical')
I also suggest you read up on selectors
Well you can use querySelectorAll
target.querySelectorAll('th.numerical'))
This will give you all th elements with className of 'numerical'.
You can create an array from element you get with getElementsByClassName and filter them like this
Array.from(target.getElementsByClassName('numerical'))
.filter((tag) => {
return tag.tagName === "TH");
});
Here I use Array.from function to convert the result of getElementsByClassName to Array as it is an instance of HTMLCollection which is not iterable.