1441422886
2017-01-03 14:49
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>if...else</title>
<script type="text/JavaScript">
var myage =30;//赵红的年龄为99
if(myage<=44)
{document.write("青年");}
else if(myage<=59)
{document.write("中年人");}
else if(myage<=89)
{document.write("老年人");}
else
{document.write("长寿老年人");}
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>if...else</title>
<script type="text/JavaScript">
var myage =30;//赵红的年龄为99
switch(myage)
{
case 1:
case 2:
''''''
case 44:document.write("青年"); break;
[其他的自己弄了。这么麻烦,为什么想用switch]
}
</script>
</head>
<body>
</body>
</html>
JavaScript进阶篇
468061 学习 · 21891 问题
相似问题