我的插件是:
$.fn.iPopup = function() {
var opts = new function() {
this.width = 957;
this.height = 590;
this.left = ($(document).width() / 2) - (this.width/2) - (17/2);
this.top = 160;
}
alert (opts.width);
}
我想在调用插件时更改宽度或高度,例如:
$('div#tP').iPopup({width:280});
我的插件应该怎么做?
答案 0 :(得分:1)
$.fn.iPopup = function(options) {
var defaults = {
'width' : 957,
'height' : 590,
'left' : ($(document).width() / 2) - (this.width()/2) - (17/2),
'top' : 160
},
opts=$.extend({}, defaults, options);
}
称之为
$('div#tP').iPopup({width:280});