「this」キーワードの範囲内でチェーンを使用して制御を維持する方法を誰かが知っているかどうか疑問に思っていました。.find(this).click を使用するとチェーンから抜け出します チェーンが壊れないようにする方法を知っている人はいますか
(function($) {
$.fn.mycontrol = function() {
$(window).resize(function() {
alert('resize')
}).scroll(function() {
alert('scroll')
}).find(document).bind('init', function() {
alert('scroll')
}).ready(function() {
$(this).trigger('init');
}).find(this).click(function() {
alert('click'); // $(this) loses scope here
});
})(jQuery);
$(document).ready(function() {
$('#mycontrol').mycontrol()
});