這個(gè)是獲取的值有問(wèn)題嗎,怎么解決呢
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>switch</title>
<script type="text/JavaScript">
function jump(){
? ??
?var myweek =document.getElementById("a");//myweek表示星期幾變量
?switch (myweek){
?case 1:
?case 2:
?alert("學(xué)習(xí)理念知識(shí)");
?break;
?case 3:
?case 4:
?alert("到企業(yè)實(shí)踐");
?break;
?case 5:
?alert("總結(jié)經(jīng)驗(yàn)");
?break;
?case 6:
?case 7:
?alert("周六、日休息和娛樂(lè)");
?break;
?default:
?alert("您的輸入有問(wèn)題!");
}
}
</script>
</head>
<body>
? ? <div>請(qǐng)輸入工作日:</div>
? ? <input type="text" id="a">
? ? <input type ="button" value = "確認(rèn)" onclick="jump()">
</body>
</html>
2018-09-29
改為?var myweek =document.getElementById("a").value; 然后在switch中改為parseInt(myweek)應(yīng)該就可以了
2022-03-27
加油。希望課程對(duì)你有幫助。不完整吆,使用confirm確定是否打開(kāi)網(wǎng)頁(yè),prompt輸入框輸入網(wǎng)址,使用open打開(kāi)輸入的網(wǎng)址。
2018-11-29
把case 1: 改成case "1":
2018-09-29
var myweek =document.getElementById("a"); 獲得的myweek 的值是string喲 可以typeof看一看就知道了