prompt的對(duì)話框沒(méi)有彈出
<!DOCTYPE?HTML> <html> <head> <meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/> <title>prompt</title> ??<script?type="text/javascript"> ??function?rec(){ var?score;?//score變量,用來(lái)存儲(chǔ)用戶輸入的成績(jī)值。 score?=prompt("請(qǐng)輸入您的成績(jī)","你的分?jǐn)?shù)是多少?"); if(score>=90) { ???document.write("你很棒!"); } else?if(score>=75) ????{ ???document.write("不錯(cuò)吆!"); } else?if(score>=60) ????{ ???document.write("要加油!"); ????} ????else { ???????document.write("要努力了!"); } ??} ??</script> </head> <body> ????<input?name="button"?type="button"?onClick="rec()"?value="點(diǎn)擊我,對(duì)成績(jī)做評(píng)價(jià)!"?/> </body> </html>
為什么我點(diǎn)擊value="點(diǎn)擊我,對(duì)成績(jī)做評(píng)價(jià)!"不能彈出對(duì)話框。
2016-12-17
2017-02-12
第9行有兩個(gè)中文標(biāo)點(diǎn)符號(hào)
正確代碼應(yīng)該是這樣:
function rec(){
? ? var score; //score變量,用來(lái)存儲(chǔ)用戶輸入的成績(jī)值。
? ? score =prompt("請(qǐng)輸入您的成績(jī)","你的分?jǐn)?shù)是多少?");
? ? if(score>=90)
? ? {
? ? ? ?document.write("你很棒!");
? ? }
? ? else if(score>=75)
? ? {
? ? ? ?document.write("不錯(cuò)吆!");
? ? }
? ? else if(score>=60)
? ? {
? ? ? ?document.write("要加油!");
? ? }
? ? else
? ? {
? ? ? ?document.write("要努力了!");
? ? }
? }