页面代码:
<div id="pic"> <img src="/dd/gg.gif" height="233"/> </div>
js代码
$(function(){ $("#pic img").each(function() { var image = $(this); if (image.width() > 435) { image.width(435); image.height(435 / image.width() * image.height()); } }); });
页面代码:
<div id="pic"> <img src="/dd/gg.gif" height="233"/> </div>
js代码
$(function(){ $("#pic img").each(function() { var image = $(this); if (image.width() > 435) { image.width(435); image.height(435 / image.width() * image.height()); } }); });