if语句的jquery,其作用类似于CSS媒体查询

if语句的jquery,其作用类似于CSS媒体查询,jquery,if-statement,media-queries,browser-width,Jquery,If Statement,Media Queries,Browser Width,我有一个jquery代码,它非常有效: $(document).scroll(function(){ if ($(this).scrollTop()>175){ // animate fixed div to small size: $('header').stop().animate({ height: 90 },100); } else { // animate fixed div to original size

我有一个jquery代码,它非常有效:

$(document).scroll(function(){
    if ($(this).scrollTop()>175){
        // animate fixed div to small size:
        $('header').stop().animate({ height: 90 },100);
    } else {
        //  animate fixed div to original size
        $('header').stop().animate({ height: 175 },100);
    }
});
我需要所有浏览器/设备始终显示并阅读上述内容,但我还需要调整较小标题的高度(当前为90px-在行下方//将固定div动画设置为小尺寸:),仅适用于641px和959px之间的浏览器宽度。我需要的标题高度为120px的浏览器宽度,否则只使用上述代码

有点像媒体查询,我希望它在浏览器调整大小时自动更新

我到底该怎么做

$(window).width();
这就是你要找的。以及

$(window).on("resize",function(){  
   if($(window).width()>641 && $(window).width()<959){
          // do the animations
   }    
}
$(窗口).on(“调整大小”,函数(){
如果($(window.width()>641&&$(window.width())
这就是你要找的。而且

$(window).on("resize",function(){  
   if($(window).width()>641 && $(window).width()<959){
          // do the animations
   }    
}
$(窗口).on(“调整大小”,函数(){
如果($(window.width()>641&&$(window.width())