").attr("src", this.src).on("load", function () { var imgw = this.width; that.css({ maxWidth:imgw }); }); }); });