這裏是我的代碼:HTML語法錯誤,innerHTML的工作不
<html>
<style type="text/css">
select {font-family: helvetica; font-size:24; text-align:center; width: 400px;}
#message {font-family:helvetica; font-size:24; text-align:center;}
</style>
<table>
<tr>
<td>
<select name="course" class="ddList">
<option value=""> (please select a course) </option>
<option value="physics">Physics</option>
<option value="calc">Calculus</option>
<option value="stats">Statistics</option>
<option value="engl">English</option>
<option value="hist">US History</option>
<option value="compsci">Computer Science</option>
</select>
</td>
<td>
<button onClick="showCourse()">Describe me!</button>
</td>
</tr>
</table>
<div id="message">Please select a course.</div>
<script>
function showCourse(){
var op = document.getElementById("course").value;
var desc = "";
if(op == "physics")
desc = "Description of AP physics goes here...";
else if(op == "calc")
desc = "Description of AP calculus goes here...";
else if(op == "stats")
desc = "Description of AP statistics goes here...";
else if(op == "engl")
desc = "Description of AP english goes here...";
else if(op == "hist")
desc = "Description of AP US history goes here...";
else if(op == "compsci")
desc = "Description of AP computer science goes here...";
else
desc = "Please select a course to see the description."
document.getElementById("message").innerHTML = desc;
}
</script>
</html>
基本上我想在div「消息」通過在下拉菜單中選擇的選項進行修改。然而它不起作用,我不知道爲什麼。我已經多次查看代碼。我認爲另一雙眼睛會有所幫助。