JavaScript学习笔记18-switch语句

来源:互联网 发布:慧讯软件 怎么样 编辑:程序博客网 时间:2024/06/05 08:50

本文来介绍JavaScript里的switch语句,switch语句一般和case,break一起使用,我们通过成绩等级划分来举例。

<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head></head><body><script type ="text/javascript">var score = "A+";switch(score){case "A+":document.write("很优秀");break;case "A":document.write("优秀");break;case "B":document.write("良好");break;case "C":document.write("及格");break;default:document.write("一般");}</script></body></html>


0 0