隔行换色

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>欢迎访问长江大学计协</title>
    <style>
        .hcls {
            background: #c5b5b5;
        }
        
        h2:hover,
        .hcls:hover {
            background: #999;
        }
        
        h2 {
            margin: 0px;
        }
    </style>
</head>

<body>

</body>
<script>
    for (i = 0; i < 10; i++) {
        if (i % 2 != 0) {
            document.write('<h2 class="hcls">' + i + '</h2>');
        } else {
            document.write('<h2>' + i + '</h2>');
        }
    }
</script>

</html

相关文章:

  • 2022-12-23
  • 2021-11-30
  • 2022-02-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-27
  • 2022-01-17
  • 2021-12-11
  • 2021-12-08
相关资源
相似解决方案