In the jquery documentation, the description of the method always states "Sets a handler ... elements of the document, or, triggers this event." For example: .scroll () Sets the "scroll" handler for the document elements, or, triggers this event. What does the scroll handler mean and what does the event trigger mean? What is their difference? Thank.
3 answers
When the scroll() expression is used, the event is triggered, that is, scrolling, and when the scroll(function(event){....}) , then a handler is assigned. This is more clear in the click() example.
To install a handler means that the actions on the page will be heard, in simple words - waiting and tracking the occurrence of the required action (event). In your case, if the "scroll" handler is installed, the page will wait for the page to scroll. As soon as scrolling is executed, the handler sees this and executes the event specified in it.
When called with the click(handler) parameter, the function adds an event handler, and if called without parameters, click() causes the event itself as a trigger('click') , which means calling all event handlers for this event (only jQuery, native will not be called) .