ul:hover li{ display: block } } .hidden-line{ display: none } </style> </head> <body> <div class="top-body"> <a href="#" ><img src="img/play.png" width="30px" height="30px" id="music-control" onclick="musiccontrol()"></a> <ul>+ <li><a href="index.html">yu</a></li> <li><a href="">yu</a></li> <li><a href="img/new.html">yu</a></li> <li><a href="homework/homework.html">yu</a></li> </ul> </ul> <h1 class="title">111111111</h1> </div> <!-- --> <div class="hidden-line" id="hidden-line"> <p>aaaaaa</p> <p>bbbbbb</p> <p>cccccc</p> <p>dddddd</p> </div> <audio src="music/mid.mp3" autoplay="false" id="music"></audio> <!--台词脚本--> <script> var title=document.getElementsByClassName("title")[0]; var title_text=title.childNodes[0]; var hidden_line=document.getElementById("hidden-line").getElementsByTagName("p") function fade_function(){ i=hidden_line.length; i=Math.floor(Math.random()*i+1); title.innerHTML=hidden_line[i-1].firstChild.nodeValue; $(".title:first").fadeIn(3000); $(".title:first").fadeOut(3000); } function musiccontrol(){ var music=document.getElementById("music-control"); var mus_attr=music.getAttribute("src"); if(mus_attr=="img/play.png"){ music.setAttribute("src", "img/mute.png"); document.getElementById('music').pause() } else{ document.getElementById('music').play(); music.setAttribute("src", "img/play.png");} } setInterval(fade_function, 6000) </script> <!--台词脚本--> </body> </html>
这个定时器一旦执行后,页面上的onclick事件变得没法点,hover也失效了