<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>js顺序播放列表中的音乐</title>
</head>
<body>
<audio controls="controls" autoplay="autoplay" id="audio" src="3.mp3" style="width:500px;"></audio>
<script type="text/javascript">
var i = 0;
var audios=[
"1.mp3",
"2.mp3",
"3.mp3"
];
document.getElementById("audio").onended = function(){
if(audios[i]){
this.setAttribute('src',audios[i]);i++;
}else{
alert('没有音乐了');
}
};
</script>
</body>
</html>