示例代码:
<div id="div_content">
<img src="http://static.cnblogs.com/images/logo_small.gif" alt="Alternate Text" />
</div>
<script type="text/javascript">
$(document).ready(function () {
var myimg;
var maxwidth = 643;
$("#div_content img").load(function () {
for (i = 0; i < $(this).length; i++) {
myimg = $(this)[i];
if (myimg.width > maxwidth) {
myimg.width = maxwidth;
}
}
});
});
</script>
本文转自田园里的蟋蟀博客园博客,原文链接:http://www.cnblogs.com/xishuai/p/js-jquery-get-img-width-heigth.html,如需转载请自行联系原作者