I have an array that contains HTML elements(I filled it with querySelectorAll()
), and I'm trying to find the index of an element in that array but the console is giving the error:
Uncaught TypeError: rows.indexOf is not a function
I used this to fill the array with the needed HTML elements:
rows = document.querySelectorAll("#selectableTableBody > tr");
and this to find the index:
document.getElementById("tableItem_10087528").onclick = function (e) {
console.log(rows.indexOf(this));
}
and here is an image of my test in the console(which doesn't make sense):
it's worth noting that these elements are generated with javascript and then put in the array using querySelectorAll()
here is a jsfiddle if you want to check the whole thing