如何在jquery中使用or和oparator?

时间:2017-01-09 14:22:02

标签: jquery html css

我正在尝试评估表达式,但我得到了#34; Uncaught SyntaxError:Unexpected token&&"为什么它会来,我不知道你能帮助我任何人吗

我试过代码:

1 个答案:

答案 0 :(得分:2)

你需要把所有的if都放在parantheses里面,然后加上双等号:

<button id="submit">Submit</button>
</form>
    <script>
    $(document).ready(function(){
        var A = 10, N = 6, D = 3, N = 0;
        $("#submit").click(function(){debugger;
        var q1 = $('input[name=q1]:checked').val();
        var q2 = $('input[name=q2]:checked').val();
        var q3 = $('input[name=q3]:checked').val();
            if((q1 == Agree || q1 == nuetral) && ((q1+q2+q3)/3 > 0.60)){
             console(q1 Agree or Nuetral and also value is above 60% );
            }
            else if((q2 == Agree || q2 ==nuetral) && ((q1+q2+q3/3) > 0.60)){
             console(q2 Agree or Nuetral and also value is above 60% );
            }
            else if((q3 == Agree || q3 == nuetral) && ((q1+q2+q3/3) > 0.60)){
             console(q3 Agree or Nuetral and also value is above 60% );
            }
            else{
                console(q1,q2 and q3 DisAgree or NotApplicable and also value is bellow 60% );
            }
        });
    });

    </script>
</body>