我在这里做错了什么? (见JS小提琴:http://jsfiddle.net/55aJt/6/)
<audio id="myAudio" src="" controls></audio>
对象
var allQuestions = [{
question: "http://www.w3schools.com/html/horse.mp3",
choices: ["3rd", "5th", "4th"],
correctAnswer: 2
},
功能
function setHeader(questionNum) {
var questionHeaderEl = document.getElementById("myAudio").src;
questionHeaderEl.innerHTML = allQuestions[questionNum].question;
}
答案 0 :(得分:0)
var questionHeaderEl = document.getElementById("myAudio").src;
questionHeaderEl.innerHTML = allQuestions[questionNum].question;
使用上面的代码,您要为元素var
值创建src
,然后尝试更改innerHtml
值的src
。它应该是这样的:
var questionHeaderEl = document.getElementById("myAudio");
questionHeaderEl.src = allQuestions[questionNum].question;
答案 1 :(得分:0)
使用
questionHeaderEl.src
而不是
questionHeaderEl.innerHTML