Plugin:
(function( $ ){
$.fn.myplugin = function( options ) {
var mymethod = function(){
// I want to be able to access "this" here ('.element')
return this;
};
return this.each(function() {
// $('.element', this).mymethod(); <- how to do this?
});
};
})( jQuery );
I want to call mymethod like this:
$('.element').mymethod();
Is this possible?
Basically it needs to keep the chaining so I can further call other functions…
If you haven’t already done so, I would highly recommend checking out the jQuery plugin authoring page. http://docs.jquery.com/Plugins/Authoring
The best way to call a specific method would be by going
The way you would achieve something like that would be like this, ( note: all taken from the jQuery plugin authoring site )