這是怎麼回事? 在我頭上的標籤......爲什麼我的功能沒有定義?
var movieArray = [
["Everything is Illuminated", "0", ""],
["The Girl Who Leapt Through Time (Toki wo kakeru shojo)", "1", "<ol><li><span class=\"bold quote_actor\">Kosuke Yoshiyama: </span><span class=\"line\">It's not that rare. Many girls do it at your age.</span></li> </ol>"],
["Freedom Writers", "0", ""],
["Inside Man", "0", ""]
];
function checkAnswer(this.value) {
if (this.value == 0) {
alert ("Wrong answer!");
} else {
alert ("Correct Answer!");
}
}
在身體...
<p><a id="0" class="btn btn-primary btn-large" value="0" onclick="checkAnswer(this.value)">Everything is Illuminated</a></p>
<p><a id="1" class="btn btn-primary btn-large" value="1" onclick="checkAnswer(this.value)">The Girl Who Leapt Through Time (Toki wo kakeru shojo)</a></p>
的錯誤是沒有定義checkAnswer()。怎麼來的?
謝謝。
你確定你沒有得到更多的錯誤嗎? '函數checkAnswer(this.value)'不是有效的JavaScript,它需要'function checkAnswer(value)' –
你在哪裏可以看到這個錯誤? – ted
你知道你的第二部電影裏有雙引號,對不對?如果將它全部定義在全局範圍內,那麼這將使所有事件都崩潰並燒燬... – Norguard