1 回答
已采纳
刚毅87
TA贡献345条经验 获得超309个赞
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style type="text/css"> *{ margin: 0; padding: 0; } div{ width: 50px; height: 50px; background: red; border-radius: 50%; display: inline-block; } </style> </head> <body> <div></div> <div></div> <div></div> <div></div> <div></div> </body> <script type="text/javascript"> var divs = document.getElementsByTagName("div"); for (var i = 0;i < divs.length;i++) { divs[i].index = i; divs[i].onclick = function () { for (var j = 0;j < divs.length;j++) { divs[j].style.background = 'red'; if (j <= this.index) { divs[j].style.background = 'blueviolet'; } } } } </script> </html>
简单写了段代码,效果完全一样,你只需要把圆改为五角星就行了.
望采纳!
添加回答
举报
0/150
提交
取消