scientiffic
scientiffic

Reputation: 9415

jquery triggered when user scrolls in div

I have a div that is scrollable:

.stepDetailView{
    float:right;
    overflow:auto;
}

I'm trying to detect when the user scrolls in the area. I know that $(window).scroll(function(){ }); works if I'm trying to detect scrolling for the entire window, but on my page, scrolling is only enabled in the div .stepDetailView.

I tried

$('.stepDetailView').scroll(function(){
  console.log("scrolling");
 });

but the log never appears in the console. Is there some other way to do this?

Thanks!

Upvotes: 0

Views: 38

Answers (1)

adeneo
adeneo

Reputation: 318182

Syntax error!

It's not:

$('.stepDetailView').scroll(function({
  console.log("scrolling");
});

but:

$('.stepDetailView').scroll(function() {
  console.log("scrolling");
});

or even:

$('.stepDetailView').on('scroll', function() {
  console.log("scrolling");
});

And then it WORKS !!!

Upvotes: 4

Related Questions