如何解决this的指向问题

function schema(arg1,arg2) {

    return this.init.call(this,arg1,arg2);

}


schema.prototype={

    init:function(a,b){

        this.a=a;

        this.b=b;

        this.arr=[];

    },

    test:function(){

        $(".selector").each(function () {

            var tt=$(this).text();

            //我想把遍历循环出来的值 tt push到 arr中   应该怎么写(或者说怎样才能使this指向schema)

        })

    }

}


var schemaObj=new schema(1,2);


叮当猫咪
浏览 550回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript