Skip to content
Advertisement

jQuery target window and a scrollable div?

I’m trying to target the scroll event for both the window and scrollable divs. Is there a way to do this in one statement?

I’ve tried…

JavaScript

Only way I have found is calling them both separately…

JavaScript

Advertisement

Answer

There may be a better way to do this, but you could use $.map to create a jquery object with both window and .boxscroll, like so:

JavaScript

EDIT: $(window).add('.box-scroll').scroll(function() { });

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement