【发布时间】:2013-04-05 03:23:56
【问题描述】:
我正在尝试使用 HTML5 中的 onEnded 属性一首一首地播放 3 首歌曲。这是我的第一次尝试,但出现错误。
错误: Uncaught ReferenceError: src is not defined
nextSong marioKart.html:49
onended marioKart.html:58
下面是我的代码:
<script>
function nextSong(){
var song = document.getElementById("player");
song.attr(src,"countdown.wav");
}
</script>
</head>
<body>
<div style="position:relative">
<audio controls autoplay="true" onEnded="nextSong()" onplay="race()" >
<source id="player" src="startMusic.wav" type="audio/mpeg" />
</audio>
有人可以帮助我实现这一目标吗?
【问题讨论】:
-
你应该使用 song.setAttribute("src", "countdown.wav");
-
另外
song没有attr方法。
标签: javascript html referenceerror