首页 > Web开发 > 详细

jQuery自定义类封装:

时间:2016-09-18 15:26:51      阅读:159      评论:0      收藏:0      [点我收藏+]

jQuery自定义类封装:

 

(function ($) {

    $.DragField = function (arg) {

        var name = "你好";     //这个是私有变量,外部无法访问

        this.testFun = function () {     //this.testFun方法,加上了this,就是公有方法了,外部可以访问。

            alert(arg.title + "," + name);

        };

    };

})(jQuery);

 

使用方法:

var a = new $.DragField({ title: "Hi" });

var b = new $.DragField({ title: "Hello" });

a.testFun();

b.testFun();

jQuery自定义类封装:

原文:http://www.cnblogs.com/PLIN/p/5881391.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!