禁用鼠标滚动 [英] Disabling mouse scrolling

查看:99
本文介绍了禁用鼠标滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有文本框的页面。当我将文本框滚动到底部时,文档将在其后滚动。如何禁用文档的鼠标滚动,但在鼠标悬停在文本框上时启用文本框的滚动?我只需要禁用鼠标滚动而不是窗口滚动条。

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.

页面有一个固定的大小,当浏览器窗口没有最大化时,只有滚动条。该文档的大小为800x600像素,应该适合我认为的大多数用户。

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.

我正在使用JavaScript和jQuery。

I'm using JavaScript with jQuery.

推荐答案

$('#txt').hover(function (){
    $('body').css('overflow','hidden');
}, function (){
    $('body').css('overflow','auto');
})

这篇关于禁用鼠标滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆