如果是Java Script中的ELSE

时间:2016-01-28 17:30:58

标签: javascript if-statement

由于某种原因,下面的代码没有应该着色。我做错了什么?

if (Group == 'Customer') {
    if (Status != 'Agreement') {
        cell.css('color', 'blue');
    }

} else if (Group == 'Non-customer') {
     if (Status == null) {
         cell.css('color', 'green');
     } else {
         if (Status != 'Agreement') {
             cell.css('color', 'yellow');
         } else if (Status == 'Not declared') {
             cell.css('color', 'purple');
         }                
     }
}

1 个答案:

答案 0 :(得分:0)

尝试以下方法:

if (Group == 'Customer') {
  if(Status != 'Agreement') {
    cell.css ('color', 'blue');
  }
}

else if (Group == 'Non-customer') {
  if (Staus == null) {
    cell.css ('color', 'green');
  }
  else if (Status != 'Agreement') {
    cell.css ('color', 'yellow');
  }  
  else if (Status != 'Not declared') {
    cell.css ('color', 'purple');
  }
}