最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

switch語句中使用prompt時(shí)

為什么獲取不到輸入框中的數(shù)?

正在回答

3 回答

問題同上,case中的選項(xiàng)需要加上引號(hào)

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

weibo_磨刀霍霍___向前沖_0 提問者

非常感謝!
2016-03-03 回復(fù) 有任何疑惑可以回復(fù)我~

是這個(gè):

<html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>switch</title>

<script type="text/JavaScript">

function DoSome(){

? ? var myweek=prompt("今天是周幾?","1");

?

? switch(myweek)

? ? {

? ? ? case 1:

? ? ? case 2:

? ? ? ? ? document.write("學(xué)習(xí)理念知識(shí)");

? ? ? ? ? break;

? ? ? case 3:

? ? ? case 4:

? ? ? ? ? document.write("到企業(yè)實(shí)踐");

? ? ? ? ? break;

? ? ? case 5:

? ? ? ? ? document.write("總結(jié)經(jīng)驗(yàn)");

? ? ? ? ? break;

? ? ? case 6:

? ? ? case 7:

? ? ? ? ? document.write("周六、日休息和娛樂");

? ? ? ? ? default:

? ? ? ? ? document.write("輸入錯(cuò)誤,不在1~7之間");

? ? }

}

</script>

</head>

<body>

<input type="button" value="時(shí)間表" onClick="DoSome()">

</body>

</html>



0 回復(fù) 有任何疑惑可以回復(fù)我~

是這樣的嗎?

<!DOCTYPE html>
<html>
<body>

<p>who are you?</p>

<button onclick="myFunction()">點(diǎn)擊這里</button>

<p id="demo"></p>

<script>
function myFunction()
{
var x;

var name=prompt("Please enter your name")
switch (name)
? {
? case "Anny":
??? x="you are Anny!";
??? break;
? case "Bnny":
??? x="you are Bnny!";
??? break;
? case "Cnny":
??? x="you are Cnny!";
??? break;
? default:
??? x="i don't know who are you!";
?? ?
? }
document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
JavaScript進(jìn)階篇
  • 參與學(xué)習(xí)       469022    人
  • 解答問題       22582    個(gè)

本課程從如何插入JS代碼開始,帶您進(jìn)入網(wǎng)頁動(dòng)態(tài)交互世界

進(jìn)入課程

switch語句中使用prompt時(shí)

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)