内部にタイムアウト機能を持つjQueryプラグインを作成しようとしています。これが私が今持っているものの基本的な考えです。正常に動作しますが、連鎖可能性は維持されません。
;(function( $ ) {
$.fn.myPlugin = function(length) {
th = $(this);
th.css('animation', 'none');
setTimeout((function(th) {
return function() {
th.css('display', 'block');
};
})(this), length);
};
})( jQuery );
連鎖可能にするためにこれを作成しましたが、TimeOut 関数でコードを実行しません。
;(function( $ ) {
$.fn.myPlugin = function(length) {
return this.each(function() {
th = $(this);
th.css('animation', 'none');
setTimeout((function(th) {
return function() {
th.css('display', 'block');
};
}),(this), length);
});
};
})( jQuery );
チェーンなしで動作するプラグインは次のとおりです: http://jsfiddle.net/FhARs/1/