JS-switch-case-根据输入的数字进入对应的文本

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>Document</title>
 </head>
 <body>
  <script>
		var input = prompt("欢迎来到中国移动\n1、查话费请按1\n2、了解宽带请按2\n3、For English press 3\n4、人工服务请按 0");
		switch(input){
			case "1":
				alert("话费查询中,请稍后...");
				break;
			case "2":
				alert("宽带业务尚未开通...");
				break;
			case "3":
				alert("Sorry,我不懂英语...");
				break;
			case "0":
				alert("人工坐席忙,请稍后...");
				break;
			default:
				alert("输入有误!!!");
		}
	</script>
 </body>
</html>

posted @ 2018-11-11 20:06  IndustriousHe  阅读(1132)  评论(0编辑  收藏  举报