在嘗試調試時,我得到這條線的'length'null錯誤。它的寫法就像書中的指示,所以我不明白爲什麼它給了我錯誤? 謝謝,=)無法讀取null(javascript)的屬性「長度」
if (capital.length < 1) {
(這裏是請求的全部代碼... SORRY)
<script type="text/javascript">
var capital = window.prompt("What is the capital of Missouri?","")
if (capital.length < 1) {
document.getElementById("firstdiv").innerHTML="Sorry you don't feel like playing.<br /> The Capital of Missouri is Jefferson City.";
}
else {
if (!window.confirm("Is that your final answer?")){ return true;
document.getElementById("firstdiv").innerHTML = "The capital of Missouri is: <bold>" + capital + "</bold>, so says you.";
}
else{
return false;
}
}
</script>
後完整的代碼,請 – frickskit
什麼語言是什麼? JavaScript的? –
因爲你從未設置過'大寫字母'。 – SLaks