switch(tagName){
case "🎜>
switch(tagName){
case "ssmm" >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後,一定要注意每個case後,一定要加:break; default,就相當於else