<html> <head> <meta charset="utf-8"> <title>无标题文档</title> <style type="text/css"> li { list-style-type: none; width: 300px; height: 30px; } </style> </head> <body> <ul> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> <script type="text/javascript"> var oli=document.getElementsByTagName(‘li‘); for(var i=0;i<oli.length;i++) { if(i%2==0) { oli[i].style.background=‘#F17B7D‘; } else { oli[i].style.background=‘#EDB461‘; } } </script> </body> </html>
时间: 2024-10-07 10:37:27