This may be easier to give an example, i’m making a jQuery plugin, i don’t want the user to pick an element to run the plugin on, just to pass it data. ie:
$('body').myPlugin({'value' : 'hey'}); //just want to pass it values, 'body' is irrelevant
How can i go about doing this?
You could use the
extendmethod:When only one argument is supplied to
extend, the object to be extended is assumed to be jQuery itself. You can then access your function as follows: