发出带有多个elseif的JavaScript问题

时间:2016-08-12 17:22:58

标签: javascript jquery if-statement

我无法运行此JavaScript,有什么建议吗?

$(document).ready(function() {
  $("form").submit(function(event){

    var like = parseInt($("input:radio[name=like]:checked").val());
    var building = parseInt($("#building").val());
    var language = parseInt($("#language").val());
    var clients = parseInt($("#clients").val());
    var study = parseInt($("input:radio[name=study]:checked").val());
    var successrate = like + building + language + clients + study;

    if(successrate <= 5 ) {
      $("#csharpOut").show();
    } elseif (sucessrate >5 or <=10) {
      $("#javaOut").show();
    } elseif (sucessrate >10 or <=18) {
      $("#phpOut").show();
    } elseif (sucessrate >18 or <=20) {
      $("#rubyOut").show();
    }else {
      $("#designOut").show();
    }
    event.preventDefault();
  });
});

2 个答案:

答案 0 :(得分:1)

elseif导致您的错误。它应该是else if

答案 1 :(得分:1)

这是else ifelseif 特定于Javascript。