如果用户没有滚动div,则调用javascript函数
如果用户没有滚动id为scrollingDiv的div,如何调用javaScript函数。我就是这样想的如果用户没有滚动div,则调用javascript函数,javascript,jquery,Javascript,Jquery,如果用户没有滚动id为scrollingDiv的div,如何调用javaScript函数。我就是这样想的 函数isScrolling(){ if(){ 警报(“滚动”); }否则{ userNotScrolling(); } IsCrolling(); SomeContent检查功能 你可以这样做: $('#scrollingDiv').on('scroll', function() { //do something while the user is scrolling the di
函数isScrolling(){
if(){
警报(“滚动”);
}否则{
userNotScrolling();
}
IsCrolling();
SomeContent
检查功能
你可以这样做:
$('#scrollingDiv').on('scroll', function() {
//do something while the user is scrolling the div
})
因为您使用的是jquery,所以可以使用
滚动事件,如:
$('#scrollingDiv').on('scroll', function() {
console.log('User scrolling the div');
})
或者:
$('#scrollingDiv').scroll(function() {
console.log('User scrolling the div');
});
希望这有帮助。你到底想要什么?在什么时候应该检查滚动?如果检查后运行userNotScrolling
,然后用户将滚动div,会发生什么情况?亲爱的,如果用户没有滚动,我需要调用函数我需要滚动div的用户底部。我可以这样做,但首先我需要检查用户是否是scr滚动。所以我需要检查用户是否在滚动。如果否,那么我将调用滚动条设置为bottmplease的函数,我不想滚动…如果没有使用if-else条件滚动,我需要创建变量isScrollingDiv=false
;如果用户滚动div,则将其设置为true
(您可以使用@Goliadkin的代码);然后在您的IsCrolling
中检查此变量。bind()
已被弃用,因此已不鼓励使用它。