<!doctype html><html><head><meta charset="utf-8"><title>123</title><script> window.onload=function(){ var oul=document.getElementById("ul"); var a = oul.getElementsByTagName("li"); for(var i =0;i<a.length;i++) { if(a[i].className=='box') { a[i].style.background='red'; } } } </script></head><body><ul id="ul"> <li class="box"></li> <li class="box"></li> <li></li> <li></li> <li class="box"></li> <li></li></ul></body></html>
添加回答
举报
0/150
提交
取消