慕仰2795485
2017-03-22 10:19
//这是我的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没引入的原因
我的效果没问题
这是我的我引入
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="Viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scaleable=no">
<meta name="format-detection" content="telephone=no">
<title>Spring festive</title>
<link href="../css/springfestive.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.min.js"></script>
<script type="text/javascript" src="../js/script.js" ></script>
这是js
window.onload=function(){
var page1=document.getElementById("page1");
var page2=document.getElementById("page2");
var page3=document.getElementById("page3");
var music=document.getElementById("music");
var audio=document.getElementsByTagName("audio")[0];
music.addEventListener("touchstart",function(event){
if(audio.paused)
{
audio.play();
this.setAttribute("class","play")}
else{
audio.pause();
this.setAttribute("class","")
};
},false);
我的也是,图片一直在转动
id="music"是不是加在图片上的
<div class="music"> <img src="images/music_pointer.png"> <img class="play" id="music" src="images/music_disc.png"> </div>
HTML5+CSS3实现春节贺卡
110057 学习 · 450 问题
相似问题