単に私は次のものを持っています:
jQuery.fn.X = function(){
    var elements = jQuery(this);
    elements.click(function(){
        var self = jQuery(this);
        //elements here is not defined why?
    });
elementsクロージャー変数として取る必要があるのに、なぜクリック関数で定義されていないのですか?
単に私は次のものを持っています:
jQuery.fn.X = function(){
    var elements = jQuery(this);
    elements.click(function(){
        var self = jQuery(this);
        //elements here is not defined why?
    });
elementsクロージャー変数として取る必要があるのに、なぜクリック関数で定義されていないのですか?
これは、jQuery プラグインを作成するための正しいアプローチです。
jQuery.fn.X = function () {
    // here, "this" will be a jQuery object containing all elements you matched
    // with X(). You must return that object.
    return this.click(function () {
        // here, "this" will be a DOM element. You don't have to return it.
        var self = jQuery(this);
        // ...
    });
});
メソッドチェーンを機能させ続けるには、jQuery を返す必要があります。