I'm working on a jQuery plugin that can be applied to multiple elements. The plugin includes some animation effects and I need to manage the event queue based on if the plugin is used on multiple elements (instead of one).
What's the best way to detect if the plugin has been applied to a single element or to multiple elements?
Edit...
The length
property works correctly if the plugin is passed multiple elements (such as $('.myClass').plugin()
) but if the plugin is called on multiple, single elements (such as $('#myElem1').plugin()
and $('#myElem2').plugin()
) then the length returns one for each call.
Is there are a way to detect multiple instances when the plugin is used as in the second example/