html5简单音乐播放图标切换

html5 music player

[code]
<html><head><script src="jquery.js"></script>
<style>

.ctr{
background:url(musicbtn.png);
background-repeat:no-repeat;
background-position:0px 0px;
height:50px;
display:block;
}

.pause{
display:block;
background-position:0 bottom;
}
</style>
</head><body><a class="ctr play" id="audioBtn" title="星座" style="cursor:pointer;">
</a>
<audio id="bgMusic" src="xz.mp3" autoplay="autoplay"></audio>

<script>
var music = document.getElementById("bgMusic");
$("#audioBtn").click(function(){
if(music.paused){music.play();
$("#audioBtn").removeClass("pause").addClass("play");

}else{
music.pause();
$("#audioBtn").removeClass("play").addClass("pause");}
});
</script></body></html>
[/code]

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>