今天写的小插件

在修改一下,暂时这样

;(function($, window, document, undefined){
    var tiance = function(element, opt){
        this.element = element; 
        this.defaults = {
            'str':'<p class="ceshi">×</p>',
            'close':'.ceshi',
            'closeCss':{'position':'absolute','left':0,'top':0,'width':'100%', 'height':'100%'}    
        },
        this.options = $.extend({}, this.defaults, opt);
    }
    tiance.prototype = {
        'repeal' : function(){
                var _this = this;
                return this.element.each(function(index, item){
                    $(item).css('position','relative').append(_this.options.str);
                    $(_this.options.close).css(_this.options.closeCss).each(function(index, select){
                        $(select).on('click',function(ev){
                            _this.options.func($(this).closest($(item)),$(this));
                    })
                })
            })
        }
    }
    $.fn.myPlugin = function (options){
         var tiance1 = new tiance(this, options);
         return  tiance1.repeal();
    }
})(jQuery, window, document);

 

posted @ 2014-12-16 15:15  北京-树苗  阅读(230)  评论(0编辑  收藏  举报