Reputation: 3097
My plugin is :
$.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);
}
I want change the width or height when I call plugin , like:
$('div#tP').iPopup({width:280});
what should I do in my plugin?
Upvotes: 1
Views: 61
Reputation: 146269
$.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);
}
Call it
$('div#tP').iPopup({width:280});
Upvotes: 1