zoukankan      html  css  js  c++  java
  • jquery监控浏览窗口尺寸变化执行相应的代码

    $(window).height(); //浏览器当下窗口可视区域高度

    $(document).height(); //浏览器当下窗口文档的高度

    $(document.body).height();//浏览器当下窗口文档body的高度

    $(document.body).outerHeight(true);//浏览器当下窗口文档body的总高度 包括border padding margin

    $(window).width(); //浏览器当下窗口可视区域宽度

    $(document).width();//浏览器当下窗口文档对象宽度

    $(document.body).width();//浏览器当下窗口文档body的高度

    $(document.body).outerWidth(true);//浏览器当下窗口文档body的总宽度 包括border padding margin

    $(document).scrollTop(); //获取滚动条到顶部的垂直高度

    $(document).scrollLeft(); //获取滚动条到左边的宽度

    //窗口大小改变时,执行:

    $(window).resize(function(){
       //执行代码块
    });

    //点击返回顶部
    $('.go_top').click(function(){
    if ($(window).scrollTop() > 0) {
    $("html,body").stop().animate({ scrollTop: 0 }, 200);
    }

    });

    $(window).scroll(function(){
    var w_h = $(document).scrollTop();
    if(w_h>300){
    $('.go_top').fadeIn();
    }
    if(w_h<=300){
    $('.go_top').fadeOut();
    }
    });

    --------------------- 本文来自 包子源 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/ziwoods/article/details/51217601?utm_source=copy 

  • 相关阅读:
    C#-获取页面源代码
    C#-获取页面源代码
    C#-窗体移动
    C#-窗体移动
    C#-窗体鼠标穿透
    C#-窗体鼠标穿透
    C#-string生成图片
    C#-string生成图片
    C#-Stmp发邮件
    POJ-1611 The Suspects
  • 原文地址:https://www.cnblogs.com/my2018/p/9726914.html
Copyright © 2011-2022 走看看