本帖最后由 danmali 于 2014-09-12 13:10:54 编辑

解决方案 »

  1.   

    试试这样行不行!return{
            this.each(function () {
                ……
            });
    }
      

  2.   

        $.fn.method = function (options,params) {
            if (typeof options == 'string') {
                switch (options) {
                    case 'subMethod': return this.each(function () { alert('子方法'+params); /*你的子方法代码*/ });
                }
            }
            var defaults = {
            // ……
        };
        var opts = $.extend(defaults, options);    return this.each(function () {
            //   ……
        });
    }
     
    //调用
    var $input = $('#input').method('subMethod',123);这样写,而不是你那样
      

  3.   

    我是要实现先生成,后调用的方式,怎么做? //调用
    var $input=$('#input').method(); //我必须先生成控件,并获得控件的对象 $input
    ……$input.subMethod();//在其它地方可能会调用这个对象的一个子方法,调用后其实是这个空间本身的一些刷新或者数据重载等
      

  4.   

    $.extend($.fn.methods, {  
    set_: function(jq, option){  

    return jq;
    }  
    }); 
      

  5.   

    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> 
    <input type="text" id="input" />
    <script type="text/javascript">
    $.fn.method = function (options) {
    var defaults = {
    name: "123"
    //……
    };
    var opts = $.extend(defaults, options);
    this.each(function () {
    //……
    });
    $this = this;
    return {
    subMethod: function (){
    $this.each(function () {
    $(this).val(opts.name);
    });
    }
    };
    };//调用
    var $input=$('#input').method();
    $input.subMethod();
    </script>
      

  6.   


    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> 
    <input type="text" id="input" />
    <script type="text/javascript">
    $.fn.method = function (options) {
    var defaults = {
    name: "123"
    //……
    };
    var opts = $.extend(defaults, options);
    this.each(function () {
    //……
    });
    var $this = this;
    return {
    subMethod: function (){
    $this.each(function () {
    $(this).val(opts.name);
    });
    }
    };
    };//调用
    var $input=$('#input').method();
    $input.subMethod();
    </script>