禁用鼠标滚动
我有一个页面,其中有一个文本框。当我将文本框滚动到底部时,文档将在其后面滚动。当鼠标悬停在文本框上时,如何禁用文档的鼠标滚动但启用文本框的滚动?我只需要禁用鼠标滚动而不是窗口滚动条。
页面大小固定,只有在浏览器窗口未最大化时才会有滚动条。该文档的大小为 800x600 像素,我认为应该适合大多数用户。
我将 JavaScript 与 jQuery 结合使用。
I have a page with a textbox in it. When I scroll the textbox to the bottom, the document will scroll after it. How to disable mouse scrolling for the document but enable scrolling for the textbox when mouse is over textbox? I only need to disable mouse scroll and not window scrollbars.
The page has a fixed size and there will only be scrollbars when the browser window is not maximized. The document has a 800x600 px size and should fit for most users I think.
I'm using JavaScript with jQuery.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用以下代码禁用滚动:
有关兼容性,请参阅:http://www.quirksmode。 org/dom/events/scroll.html
Use the following code to disable scrolling:
For compability, see: http://www.quirksmode.org/dom/events/scroll.html
此解决方案与 Sameera 相同,但没有 Jquery:
This solution is same of Sameera but without Jquery:
您可以尝试以下操作,
如果您选择使用以下命令,也可以在 CSS 中执行此操作;
我突然想到了这一点。如果您不希望它们滚动,您还可以向 CSS 类添加一些内容,如下所示
希望这会有所帮助!
快乐编码! ;)
You could try the following
You could also do this in CSS if you choose to do so using the following;
Off the top of my head I came up with that. If you don't want them to scroll you could also add some stuff to your CSS class like the following
Hope this helps!
Happy Coding! ;)