jQuery插件模板


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);

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。