Javascript脚本:Switch语句
switch语句用于从多种选择路线中选择一条路线执行的情况。
与Vbscript中的select…case语句非常相似
swithc语句的语法格式:

  1. switch (expressin){
  2. case labe1 :
  3. statements;//条件表达式
  4. breadk;
  5. case labe2 :
  6. statements;
  7. breadk;
  8. }

写个代码示例:

  1. var color = promt("选择你喜欢的色彩-红,蓝,黄","");
  2. switch (color){
  3. case "红"
  4. document.wirte("红");
  5. break;
  6. ...........
  7. }

还有种情况如果有个条件case “expression”满足的话可写成
Read the rest of this entry »

,