您的位置: 首页-> 电脑文摘-> 网站开发-> 其它-> 正文

javascript里类似select case该如何用
作者佚名 来源InterNet 加入时间:2005-4-1
switch Statement<br>
Enables the execution of one or more statements when a specified expression's value matches a label.<br>
<br>
switch (expression) {<br>
&nbsp;&nbsp;&nbsp;case label :<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statementlist<br>
&nbsp;&nbsp;&nbsp;case label :<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statementlist<br>
&nbsp;&nbsp;&nbsp;...<br>
&nbsp;&nbsp;&nbsp;default :<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statementlist<br>
} <br>
<br>
Arguments<br>
expression<br>
<br>
The expression to be evaluated.<br>
<br>
label<br>
<br>
An identifier to be matched against expression. If label === expression, execution starts with the statementlist immediately after the colon, and continues until it encounters either a break statement, which is optional, or the end of the switch statement.<br>
<br>
statementlist<br>
<br>
One or more statements to be executed.<br>
<br>
Remarks<br>
Use the default clause to provide a statement to be executed if none of the label values matches expression. It can appear anywhere within the switch code block. <br>
<br>
Zero or more label blocks may be specified. If no label matches the value of expression, and a default case is not supplied, no statements are executed.<br>
<br>
Execution flows through a switch statement as follows: <br>
<br>
Evaluate expression and look at label in order until a match is found. <br>
If a label value equals expression, execute its accompanying statementlist. <br>
Continue execution until a break statement is encountered, or the switch statement ends. This means that multiple label blocks are executed if a break statement is not used. <br>
If no label equals expression, go to the default case. If there is no default case, go to last step. <br>
Continue execution at the statement following the end of the switch code block. <br>
Example<br>
The following example tests an object for its type. <br>
<br>
function MyObject() {<br>
...}<br>
<br>
switch (object.constructor){<br>
&nbsp;&nbsp;&nbsp;case Date:<br>
&nbsp;&nbsp;&nbsp;...<br>
&nbsp;&nbsp;&nbsp;case Number:<br>
&nbsp;&nbsp;&nbsp;...<br>
&nbsp;&nbsp;&nbsp;case String:<br>
&nbsp;&nbsp;&nbsp;...<br>
&nbsp;&nbsp;&nbsp;case MyObject:<br>
&nbsp;&nbsp;&nbsp;...<br>
&nbsp;&nbsp;&nbsp;default: <br>
&nbsp;&nbsp;&nbsp;...<br>
}<br>
Requirements<br>
Version 3<br>
<br>


[文章录入员:nancy]

相关文章
  • 在javascript中调用vbscript的函数,构造一个javascript版的trim 函数
  • javascript表单之间的数据传递
  • 一个简单的javascript菜单
  • 一组JavaScript绘图函数
  • asp自动生成javascript检验函数
  • 用JavaScript实现利用FLASH嵌入声音
  • Javascript设计漫天雪花
  • Javascript模拟游戏中的弹出菜单效果
  • 利用JAVASCRIPT制作简单动画
  • 首页地址添加到收藏夹(javascript)
  • 相关软件:
  • JavaScript 权威指南(第四版)
  • JavaScript傻瓜指南
  • ::PCBOOKCN'ADS::


    ::其它::
    ASP/ASP.NET
    PHP技术
    JSP技术
    XML技术
    CGI/PERL
    WEB服务器
    其它
    ::阅读排行::
    ·VBScript 函数集
    ·网站建设步骤
    ·网上建站论坛的选择和安装(菜鸟版...
    ·关于SQL语句中的引号问题(VB...
    ·用ASP动态生成JavaScri...
    ·Apache+PHP+MySQL...
    ·用VBScript实现对Wind...
    ·VBScript和JavaScr...
    ·一个简单的javascript菜...
    ·VBScript函数补习课