var found=3, elems=document.querySelectorAll('.primer > span'); for(var i=0;i<elems.length;i++){ if(parseInt(elems[i].innerHTML)==found){ elems[i].style.color='red'; break; }; };