Home  >  Article  >  Web Front-end  >  Introduction to usage examples of js switch case default_javascript skills

Introduction to usage examples of js switch case default_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:19:031677browse
Copy code The code is as follows:

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;
}
The above statement is equivalent to
if(tagName == " span"){
node = element.parent().parent();
element = element;
}else if(tagName == "td"){
node = element.parent( );
element = element.find("span");
}else{
node = element;
}

After paying attention to each case, be sure to Add: break;
default, which is equivalent to else
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn