Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        3年前关闭。
                                                                                            
                
        
我的代码无法正常工作。这是汉堡包菜单

$("#nav-button").on("click", function(){
    if
    ($("#list-nav").css('display') == 'none');
    $("#list-nav").slideDown(300);

    else

    ($("#list-nav").css('display') == 'block');
    $("#list-nav").slideUp(300);
    $(".hamburger").removeClass( "is-active" )

});

最佳答案

if-else语句似乎不正确

$("#nav-button").on("click", function(){
  if($("#list-nav").css('display') == 'none') {
    $("#list-nav").slideDown(300);
  } else {
    $("#list-nav").slideUp(300);
    $(".hamburger").removeClass( "is-active" )
  }
});

10-07 17:47