<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>音乐播放器</title>
<style type="text/css">
body{
background: url(images/bg.jpg) no-repeat;
}
#toggle{
position: absolute;
left: 311px;
top: 293px;
}
</style>
<audio id="music">
<source src="medias/Wah Game Loop.ogg">
<source src="medias/Wah Game Loop.mp3">
</audio>
<button id="toggle" onclick="toggleSound()">
播放
</button>
<script type="text/javascript">
function toggleSound(){
var music = document.getElementById("music");
var toggle = document.getElementById("toggle");
if (music.paused) {
music.play();
// innerHTML 属性设置或返回表格行的开始和结束标签之间的 HTML
// HTMLElementObject.innerHTML=text
toggle.innerHTML = "暂停";
}else{
music.pause();
toggle.innerHTML = "播放";
}
}
</script>
</head>
<body>
</body>
</html>













网友评论