面向对象插件框架
;(function($){
function Center(el,opt){
this.$el = el
this.defaluts = {
"width":100
}
this.settings = $.extend(this.defaluts,opt)
}
Center.prototype = {
a:function(){
}
}
$.fn.center = function(options){
var center = new Center(this,options)
return center.a()
}
})(jQuery)
面向对象插件修改表格属性
;(function($){
//对象级别
$.fn.center = function(options){
var defaults = {
"position":"absolute",
"background":"red",
"width":100,
"height":100
}
var options = $.extend(defaults,options);
this.each(function(){
//功能实现逻辑
var _this = $(this)
var _vH = ($(window).height()-options.height)/2
var _vW = ($(window).width()-options.width)/2
_this.css({
"background":options.background,
"position":options.position,
"width":options.width,
"height":options.height,
"left":_vW,
"top":_vH
})
})
return this
}
})(jQuery)