課程
/前端開發
/JavaScript
/JavaScript入門篇
這個用prompt應該先跳出來輸入成績的,怎么寫的?
2017-03-28
源自:JavaScript入門篇 2-4
正在回答
score?=prompt("請輸入分數","80");
80是提示輸入框自動顯示的分數
<!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 = 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>
試試我這個吧~
<!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("請輸入你的成績","520!"); ????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>
<!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>
白狼x 提問者
changings 回復 白狼x 提問者
舉報
JavaScript做為一名Web工程師的必備技術,本教程讓您快速入門
3 回答這個代碼怎么寫
4 回答這個問題的代碼怎么寫呀
3 回答這個代碼怎么錯了
2 回答怎么寫script代碼?
2 回答怎么完善這個代碼?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-05-14
score?=prompt("請輸入分數","80");
80是提示輸入框自動顯示的分數
2017-04-04
<!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 = 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>
2017-03-30
試試我這個吧~
2017-03-28