单击div时无法播放音频文件

时间:2016-06-08 12:40:35

标签: javascript

有人可以帮我理解为什么我的音频不会播放?

HTML:

<div id = "One" class = "square" onmousedown = "playSound(1)" ></div>
<audio id = "sound1" src = "https://s3.amazonaws.com/freecodecamp/simonSound1.mp3"/>

JS:

function playSound(val) {
var soundToPlay = document.getElementByID("sound"+val);
soundToPlay.play();
}

非常感谢:)

1 个答案:

答案 0 :(得分:0)

您在Content-Type处有一个大写D的拼写错误:

Id

改为:

getElementByID
//-this -----^