var td = document.getElementsByTagName('td'), i = 0, tdLength = td.length; for(;i<tdLength;i++){ td[i].onmouseover = function(){...piwpiw...} }