Javascript 滚动div元素时防止整页滚动

Javascript 滚动div元素时防止整页滚动,javascript,jquery,html,css,scroll,Javascript,Jquery,Html,Css,Scroll,我想防止在div元素中滚动时页面滚动到上一页。现在我正在使用Alvarotrigo的全页滚动,不确定这是否相关。 基本上,这个页面有两个“页面”。“.table responsive”位于第2页,我已将其设置为溢出:滚动。在该div中向上滚动时,它也会向上滚动到第一页 我已经试过了,但不起作用: $('.table-responsive').on( 'mousewheel DOMMouseScroll', function (e) { var e0 = e.originalEvent; va

我想防止在div元素中滚动时页面滚动到上一页。现在我正在使用Alvarotrigo的全页滚动,不确定这是否相关。 基本上,这个页面有两个“页面”。“.table responsive”位于第2页,我已将其设置为溢出:滚动。在该div中向上滚动时,它也会向上滚动到第一页

我已经试过了,但不起作用:

$('.table-responsive').on( 'mousewheel DOMMouseScroll', function (e) { 

var e0 = e.originalEvent;
var delta = e0.wheelDelta || -e0.detail;

this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
e.preventDefault();  
});

认为这就是您要寻找的

只需将溢出隐藏到body元素即可。适合我的情态动词这不是我想要的
.table-responsive {
max-width: 70%;
}
or
.table-responsive {
max-width: 250px;
}
.table-responsive {
width: 70%;
text-align: left;
margin-top: 30px;
margin-bottom: 30px;
margin-left: auto;
margin-right: auto;
height: 40vh;
overflow: scroll;
border: 3px solid #fff;
background-color: rgba(0,0,0,0.6); 
}
$('.table-responsive').on('mouseover', function(){
  $('body').css('overflow', 'hidden');
}).on('mouseout', function(){
  $('body').css('overflow', 'auto');
});
.table-responsive {
max-width: 70%;
}
or
.table-responsive {
max-width: 250px;
}