function countOnline() { var tds = document.getElementById('table1').getElementsByTagName('tr'), counter = 0; for(var i=0, l=tds.length; i<l; i++) { if(tds[i].getElementsByTagName('td')[1].innerHTML === 'Онлайн') { counter++; } } return counter; }