jQuery或Javascript - 如何禁用窗口滚动没有overflow:hidden; [英] jQuery or Javascript - how to disable window scroll without overflow:hidden;
问题描述
您可以禁用窗口滚动,而不使用 overflow:hidden;
当我悬停元素时?
i tryed:
$('chat-content')。on('mouseenter',function(){
$(document).scroll(function(e){
if(!$(e).hasClass('chat-content'))
e.stopPropagation();
e.preventDefault();
});
});
我的意思是,我想保留可见的滚动条,但当我滚出元素用鼠标,窗口不滚动,而元素我已经结束可以滚动
因此禁用滚动的身体,但不是为元素,我没有使用css
这里是另一种尝试: http://jsfiddle.net/SHwGL/
尝试在所有节点上处理'mousewheel'事件,除了一个
$('body')。on({
pre>
'mousewheel':function(e){
if(e.target.id == 'el')return;
e.preventDefault();
e.stopPropagation();
}
})
演示: http://jsfiddle.net/DHz77/1/
Hi is it possible to disable window scrolling without using
overflow:hidden;
when i'm hover an element?i tryed :
$('.chat-content').on('mouseenter',function(){ $(document).scroll(function(e){ if(!$(e).hasClass('.chat-content')) e.stopPropagation(); e.preventDefault(); }); });
i mean, i want to leave visible the scrollbar but when i scroll out of the element i'm over with mouse the window doesn't scrolls, while the element i'm over can scroll
So disable scroll for body but not for element i'm over without using css
here is another try i did: http://jsfiddle.net/SHwGL/
解决方案Try to handler 'mousewheel' event on all nodes except one
$('body').on({ 'mousewheel': function(e) { if (e.target.id == 'el') return; e.preventDefault(); e.stopPropagation(); } })
Demo: http://jsfiddle.net/DHz77/1/
这篇关于jQuery或Javascript - 如何禁用窗口滚动没有overflow:hidden;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!