复制代码 代码如下:
switch(tagName){
case "span":
node = element.parent().parent();
element = element;
break;
case "td":
node = element.parent();
element = element.find("span");
break;
default:
node = element;
break;
}
以上语句等同于
if(tagName == "span"){
node = element.parent().parent();
element = element;
}else if(tagName == "td"){
node = element.parent();
element = element.find("span");
}else{
node = element;
}
注意每个case后,一定要加:break;
default,就相当于else
switch(tagName){
case "span":
node = element.parent().parent();
element = element;
break;
case "td":
node = element.parent();
element = element.find("span");
break;
default:
node = element;
break;
}
以上语句等同于
if(tagName == "span"){
node = element.parent().parent();
element = element;
}else if(tagName == "td"){
node = element.parent();
element = element.find("span");
}else{
node = element;
}
注意每个case后,一定要加:break;
default,就相当于else
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“js switch case default 的用法示例介绍”评论...