Reputation: 241
I hope this should work. But, I don't know why its not working. Actually I'm trying to find the number of rows in a table which are having "active"class .
var p_rcd = document.getElementById('tblAllMessages').
getElementsByTagName("tbody")[0].
getElementsByTagName("tr"). getElementsByClassName('active').length;
getElementsByClassName returns an array of elements. Am I going in wrong direction?
Upvotes: 0
Views: 91
Reputation: 256
Try the below:
var table = document.getElementById("tblAllMessages").getElementsByTagName("tbody")[0].getElementsByClassName('active').length;
alert(table);
Upvotes: 0
Reputation: 1012
var rows = document.getElementById("tblAllMessages").getElementsByTagName("tbody")[0].getElementsByClassName("active").length;
alert(rows);
Upvotes: 2