js路径正确,代码好像也没错,音乐跟图片都停不了
//这是我的js代码 window.onload = function(){ var music = document.getElementById("music"); var audio = document.getElementsByTagName("audio")[0]; music.onclick = function(){ if(audio.paused){ audio.play(); this.setAttribute("class","play"); }else{ audio.pause(); this.setAttribute("class",""); }; }; }; //这是我的引入代码 <!doctype html> <html> <head> <meta charset="utf-8"> <title>迎春</title> <link rel="stylesheet" type="text/css" href="css/style.css"> <script type="text/javascript" src="js/script.js"></script> </head>
我的css跟js也没放到一个文件夹,难道是编写js需要格外装些库啥的我没装,还是jequery没引入的原因