我正在尝试评估表达式,但是我收到“ Uncaught SyntaxError:意外令牌&&”,为什么会出现我不知道您能帮我一个忙吗
我尝试了代码:

最佳答案

您需要将所有的if放在括号内,并加倍等号字符:

<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>

关于jquery - 如何在jQuery中使用or以及运算符?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41550064/

10-10 00:11