What are jQuery hooks and callbacks?

后端 未结 2 2183
独厮守ぢ
独厮守ぢ 2021-02-19 15:24

I am having a tough time conceptualizing what exactly callbacks or hooks are in jQuery. They seem to be lumped together, but I don\'t know the difference between them.

F

2条回答
  •  孤城傲影
    2021-02-19 16:11

    I would guess in the context you've seen the word used people mean callbacks, which are exactly what you think they are (in the case of jQuery a hook and a callback are the same thing).

    A callback for jQuery's animate() function for instance will execute as soon as the animation has completed.

    Some built in functions and other jQuery plugins might define multiple callbacks for various stages of of execution. For instance a plugin that displays a popup box for a user might have a callback for when the user clicks on a link to show the box, but before the box is actually displayed (this callback could be used to store some data the actual popup will need, for instance). The same popup functions might also execute a callback function when the box is closed again - this callback could be used to make a change to the page, or save some data for instance.

提交回复
热议问题