<body> <ul id="ul"> <li class="a abc abcd abcde ">1</li> <li class="c a">2</li> <li class="aa">3</li> <li class="a c b r f">4</li> <li class="b">5</li> </ul> <div id="div"> <b class="div">12312</b> <div class="divvv">aisdjfoa </div> <h1 class="div div1"> 23456</h1> <p class="div2 "> pppp</p> </div>
<script>
for(var i=0;i<rua("div","div").length;i++){
rua("div","div")[i].style.color="blue";
}
function rua(ul,a) {
var oUL=document.getElementById(ul);
var arrLi=oUL.getElementsByTagName("*");
var arLII=[];
for(var i=0;i<arrLi.length;i++) {
var arrString=arrLi[i].className.split(" ");
for(j in arrString) {
if (arrString[j]==a) {
arLII.push(arrLi[i])
}
}
}
return arLII;
}
for (var i=0;i<rua("ul","a").length;i++){
rua("ul","a")[i].style.background="red";
}
</script>
</body>