jquery类继承

前端之家收集整理的这篇文章主要介绍了jquery类继承前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
var A=function(){
};

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

};

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

以上是在jQuery中创建类和继承的最好方法吗?在B的init中,如何调用父类的init(类似于OO语言的super.init())?

解决方法

对于OO,最好在jQuery外面看。 jQuery是基于选择器返回的集合。

如果你想上课,有些选择是Base2JooseJS.Class

原文链接:https://www.f2er.com/jquery/183356.html

猜你在找的jQuery相关文章