Chinaunix首页 | 论坛 | 博客
  • 博客访问: 46343
  • 博文数量: 42
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 265
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-11 10:39
文章分类
文章存档

2015年(12)

2014年(30)

我的朋友

分类: jQuery

2014-12-08 17:31:18


jQuery插件模板

制作JQuery插件的基本框架
演示:


(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"
        },
        
        _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);

 

阅读(237) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~