jquery class inheritance

后端 未结 6 2032
清歌不尽
清歌不尽 2020-12-24 02:41
var A=function(){
};

$.extend(A.prototype, {
    init:function(){
        alert(\'A init\');
    }
});
var B=function(){

};

$.extend(B.prototype,A.prototype,{
            


        
6条回答
  •  萌比男神i
    2020-12-24 03:18

    John Resig created a snippet for simple inheritance here. http://ejohn.org/blog/simple-javascript-inheritance/

    he stores the super class to a _super variable so you can call it like such

    this._super();
    

    you can reference his code snippet to get a better idea of what he another helpful post is: http://alexsexton.com/?p=51

提交回复
热议问题