I have a question regarding the working of jQuery bind. Whenever we use the bind method on any element and write some callback code, does that complete code get executed on the bind event "each time" OR does jQuery only remember the output/result of that code and executes only that result..
Also can we generate another event inside the callback code?
Like how does it work exactly.
Every time an event is triggered, all functions bound to the event on the specified target get executed. Return values for those callback functions are used to determine if the event should continue to propagate.
There are a few significant differences between a function invoked as part of a script and an event callback:
thisrefers to the bound element that the event was assigned to)imay have their final value by the time the callback is called)As callbacks are just functions, they can do anything that any other function can do, including calling
trigger. Do be careful not to cause yourself an infinite loop with recursive function calls to the same event.You wouldn’t want to call:
Likewise, you wouldn’t want to call: