$("#baiduContent img").each(function (i) { var img = $(this); var realWidth; //var realHeight; $("<img/>").attr("src", $(img).attr("src")).load(function () { realWidth = this.width; //realHeight = this.height; if (realWidth >= 300) { $(img).css("width", "100%").css("height", "auto"); }
//else { //$(img).css("width", realWidth + 'px').css("height", realHeight + 'px'); //} }); });