AI编程助手
AI免费问答

jquery判断是否出现滚动条的方法

藏色散人   2020-12-14 10:14   3408浏览 原创
jquery判断是否出现滚动条的方法:1、通过“if ($(window).height()

本教程操作环境:windows7系统、jquery1.10.0版本、thinkpad t480电脑。

推荐:《jquery视频教程

jquery判断是否出现滚动条

一、判断可视区域是否超过实际高度,超过一定存在

if ($(window).height() <p>使用原生JavaScript的写法</p><pre class="brush:php;toolbar:false">if (document.documentElement.clientHeight <p>二、屏幕可用工作区高度>=网页可见区域</p><pre class="brush:php;toolbar:false">if (window.screen.availHeight >= document.body.clientHeight) {
  alert("页面无滚动条")
} else {
    alert("页面有滚动条")
}

注:

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

document.documentElement.clientHeight

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

document.documentElement.offsetHeight

● window.screen.availHeight // 屏幕可用工作区高度

● document.body.clientHeight // 网页可见区域

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。