プラグイン:関数変数をjqueryプラグインのように呼び出す方法を教えてください。
(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);
私はこのようにmymethod呼びたい:
$('.element').mymethod();
これは可能ですか?
は、基本的には
ラッピング関数を取り除き、単に '$'エイリアスを他の場所で使用できるようにしたいのでない限り、 'jQuery.fn.myplugin'に代入することができます。 – davidchambers