I\'m looking at a jQuery plugin, which has a single function. After setting up the appropriate defaults though a constructor argument the function defines a couple of helper fu
It allows for one to call a plugin or an event on a bunch of elements and then apply that same function or event to all of them
So if you do:
$('.selector').myPlugin();
And if, let us say, .selector
contains 10 elements, all 10 elements would get whatever myPlugin
does.
The reason for returning that .each
statement is because .each()
returns whatever it was given and it allows you to chain multiple functions and plugins together on one jQuery element.
For example:
$('.selector').myPlugin().yourPlugin();