在sublime編寫后測試時點擊按鈕沒反應(yīng)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>prompt提問彈窗</title>
<script type="text/javascript">
function rec(){
var score=prompt("請輸入成績");
if(score>=90) {
document.write("你很棒!");
}
else if (score>=70) ;
{
document.write("不錯呦!");
}
else if (score>=60) ;
{
document.write("要加油!");
}
else{
document.write("要努力了!");
}
}
</script>
</head>
<body>
<input type="button" name="button" value="點擊測試成績" onclick="rec()">
</body>
</html>
求指點哪里錯了,為什么點擊按鈕的時候沒有反應(yīng)?
2016-03-18
一條完整的語句后面才打分號,else if()后面是不打分號的,else if(){document.write(".....");//這里才打分號}
2016-03-25
sublime,你試試Ctrl+e
2016-03-18
我剛剛也試了一下,把分號改過來了,還是不行
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>prompt提問彈窗</title>
<script type="text/javascript">
function rec(){
var score=prompt("請輸入成績");
if(score>=90) {
document.write("你很棒!");
}
else if (score>=70)?
{
document.write("不錯呦!");
}
else if (score>=60)
{
document.write("要加油!");
}
else{
document.write("要努力了!");
}
}
</script>
</head>
<body>
<input type="button" name="button" value="點擊測試成績" onclick="rec()">
</body>
</html>
2016-03-18
樓上已經(jīng)把問題說了,新手切記 中英文輸入法中午輸入法是會報錯的,語法知識一定要牢固。加油
2016-03-18
有些分號的位置打錯了,有些分號的中英文沒有切換,分號弄成中文了。
2016-03-18
你刷新一下網(wǎng)頁就好了,代碼沒錯