Closed. This question is not reproducible or was caused by typos。它当前不接受答案。
                        
                    
                
            
        
            
        
                
                    
                
            
                
                    想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                
                    4年前关闭。
            
        

    

我在使它工作时遇到问题。这段代码在这里工作:

if ($('.test').is(':visible')) {
    if ($('.test').val() >= 1 )) {
        $(".test .section").show();
        $("#something").hide();
    } else {
        $(".test .section").hide();
    }
}


但是,当我尝试添加&&运算符以指定范围时,出现一条错误消息,提示它不是函数:

if ($('.test').is(':visible')) {
    if ($('.test').val() >= 1 && ('.test').val() <= 100)){
        $(".test .section").show();
        $("#something").hide();
    } else {
        $(".test .section").hide();
    }
}


我也尝试过:

if ($(('.test').val() >= 1) && (('.test').val() <= 100)))


我不知道为什么这不起作用。

最佳答案

这个

if(($('.test').val() >= 1) && ($('.test').val() <= 100))


您有一个额外的),需要添加$

07-24 09:50
查看更多