jQuery JS 禁用滚动条和启用滚动条
来源:互联网 发布:程序员 网络工程师 编辑:程序博客网 时间:2024/05/29 23:46
CSS:
.lock { overflow: hidden; touch-action: none; } .lock body { overflow: hidden; touch-action: none; margin-right: 17px; } .lock.mobile body { margin-right: 0; }
JS:
var methods = { /** 禁用滚动*/ forbidScroll: function () { document.querySelector("html").classList.add("lock"); window.addEventListener("mousewheel", this.forbidScroll); window.addEventListener("touchmove", this.forbidScroll, { passive: false }); }, /** 启用滚动*/ enabledScroll: function () { document.querySelector("html").classList.remove("lock"); window.removeEventListener("mousewheel", this.forbidScroll); window.removeEventListener("touchmove", this.forbidScroll, { passive: false }); } }
调用方法:
$("#test1").click(function () { methods.forbidScroll(); }); $("#test2").click(function () { methods.endabledScroll(); });
阅读全文
0 0
- jQuery JS 禁用滚动条和启用滚动条
- JQuery 禁用启用滚动条方式
- js禁用滚动条
- js禁用滚动条
- 禁用页面滚动条
- javascript禁用浏览器滚动条
- HTML禁用竖向滚动条
- jquery.nicescroll.js 滚动条插件 API
- extjs/jquery/js 操作页面滚动条
- jquery.nicescroll.js 美化滚动条
- jquery浏览器滚动条
- jquery 滚动条事件
- JQuery 滚动条实现
- Jquery操作滚动条
- JQuery Slider(滚动条)
- jquery 滚动条事件
- JQuery滚动条事件
- js控制滚动条
- a标签 功能性打开qq迅雷 邮件的方法
- openstack 1.7.2 +centos 7.2 + nova 12.0.4 搭建
- 64. Minimum Path Sum
- 基于OpenStack Ocata版本源码分析-oslo
- tcp的三次握手和四次挥手、长链接和短链接
- jQuery JS 禁用滚动条和启用滚动条
- Longest Substring without Repeating Characters
- (无监督学习&&视频预测)所读论文[1]:PredNet
- MD5
- oracle表空间
- 在SCDN上的第一篇博客
- Atcoder Regular Contest 081 总结
- 2017.8.22坐标问题
- 【NOIP2017提高A组模拟8.22】密码