我的代码:
(function($){
$.fn.extend({
popupbox: function(options) {
//Settings list and the default values
var defaults = {
photo_url : "",
photo_id : ""
};
var options = $.extend(defaults, options);
return this.each(function() {
var o = options;
//Assign current element to variable
var obj = $(this);
var photo_pic = $('#photo_box_img');
photo_pic.attr("src", o.photo_url);
photo_pic.load(function() {
var pic_width = photo_pic.width();
var pic_height = photo_pic.width();
console.log(pic_width);
}
});
}
});
})(jQuery);
我第一次click
使用上面的image
按钮click() function
返回0但next time
它......为什么会这样?shows
proper width