K
K
krock000002020-01-22 14:06:54
PHP
krock00000, 2020-01-22 14:06:54

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

2 answer(s)
A
akamap, 2019-04-17
@akamap

for ( ; count($json_array) = 0; $reg = $reg - 1) {

V
v3shin, 2020-01-22
@krock00000

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 question

Ask a Question

731 491 924 answers to any question