i have a table with number :
<td id="table-number">{{ $loop->index + 1 }}</td>
now i want to get the number of "9" from the table row
Here is what i do :
const number = document.getElementById('table-number');
if(number.textContent.includes('9')) {
console.log('heyhey');
}
but it returns nothing. So, what should i do? I expect to get the table number.
ok guys, i got the answer at this post, sorry i didnt serach thoroughly. Need to upgrade my google skils
2
Answers
You probably don’t need an id or a class on the cells.
Use
querySelectorAll
to get a node list of all of the cells, coerce the node list to an array, and thenfind
the cell with the text content that includes your query.Assuming the
<td>
elements are produced in a loop and you want to know if any of them contain a9
, give the elements a class instead of id…and try something like this instead