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