prompt的對話框沒有彈出
<!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變量,用來存儲用戶輸入的成績值。 score?=prompt("請輸入您的成績","你的分數是多少?"); if(score>=90) { ???document.write("你很棒!"); } else?if(score>=75) ????{ ???document.write("不錯吆!"); } else?if(score>=60) ????{ ???document.write("要加油!"); ????} ????else { ???????document.write("要努力了!"); } ??} ??</script> </head> <body> ????<input?name="button"?type="button"?onClick="rec()"?value="點擊我,對成績做評價!"?/> </body> </html>
為什么我點擊value="點擊我,對成績做評價!"不能彈出對話框。
2016-12-17
2017-02-12
第9行有兩個中文標點符號
正確代碼應該是這樣:
function rec(){
? ? var score; //score變量,用來存儲用戶輸入的成績值。
? ? score =prompt("請輸入您的成績","你的分數是多少?");
? ? if(score>=90)
? ? {
? ? ? ?document.write("你很棒!");
? ? }
? ? else if(score>=75)
? ? {
? ? ? ?document.write("不錯吆!");
? ? }
? ? else if(score>=60)
? ? {
? ? ? ?document.write("要加油!");
? ? }
? ? else
? ? {
? ? ? ?document.write("要努力了!");
? ? }
? }