Answer the question
In order to leave comments, you need to log in
What is the difference between scroll() and on('scroll', function() {...});?
Good afternoon.
Please tell me what is the difference between $(document).scroll( function() {...} ); and $(document).on( 'scroll', function() {...} )
Answer the question
In order to leave comments, you need to log in
scroll(handler) is an alias for $(document).on( 'scroll', handler). But in the second case, you can use the $(document).on('scroll', selector, handler) syntax, which allows you to hang events on selectors, not elements (the handler will also work on those elements that are not yet on the page).
https://api.jquery.com/on/#on-events-selector-data...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question