首页 > Web开发 > 详细

jQuery插件模板

时间:2014-12-08 19:26:38      阅读:361      评论:0      收藏:0      [点我收藏+]


jQuery插件模板

制作JQuery插件的基本框架
演示:http://www.huiyi8.com/chajian/


(function($){
    //The jQuery.aj namespare will automatically be created if it doesn‘t exist
    $.widget("aj.filterable",{
        //These options will be used as defaults
        options: {className : "" },
         
        _create: function(){
            //The _create method is where you set up the widget
        },
                 
        //Keep various pieces of logic in separate methods
        filter: function(){
            //Methods without an underscore are "public"
        },
        jquery插件库  
        _hover: function(){
            //Methods with an underscore are " private"
        },
         
        _setOption: function(key, value){
            //Use the _setOption method to respond to changes to options
            switch(key){
                case "length":
                    break;
            }   
            $.Widget.prototype._setOption.apply(this,arguments)
        },
        destroy: function(){
            //Use the destory method to reverse everything your plugin has applied
            $.Widget.prototype.destroy.call(this);
        }   
    });
})(jQuery);

 

jQuery插件模板

原文:http://www.cnblogs.com/lhrs/p/4151582.html

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