var h3_elems=document.getElementsByTagName('h3'); for(var i=0;i<h3_elems.length;i++){ if(h3_elems[i].className=='nav1'){ //....PROFIT } }