js switch case default 的用法示例介绍
代码如下:
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
相关推荐
boneix 2020-10-21
seanzed 2020-10-15
ifconfig 2020-10-14
学留痕 2020-09-20
往后余生 2020-09-17
kka 2020-09-14
redis 2020-09-07
lzccheng 2020-09-06
soyo 2020-08-31
stonerkuang 2020-08-18
LxyPython 2020-08-17
raksmart0 2020-08-17
Lzs 2020-08-14
MrHaoNan 2020-07-31
80530895 2020-07-05
lengyu0 2020-06-28
YarnSup 2020-06-28
huanglianhuabj00 2020-06-27