简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

js重置图片的高宽

来源:易贤网   阅读:1033 次  日期:2014-12-08 10:49:01

温馨提示:易贤网小编为您整理了“js重置图片的高宽”,方便广大网友查阅!

<script type=text/javascript>

//正文图片内容溢出处理

function redrawimage(obj) {

var boxwidth = 680; // $(obj).width() - 20;

$(obj + img).each(function () {

var imgwidth = $(this).width();

var imgheight = $(this).height();

if (imgwidth > boxwidth) {

$(this).width(boxwidth);

$(this).height(boxwidth / imgwidth * imgheight);

}

})

$(obj + table table).each(function () {

if ($(this).width() > boxwidth) {

$(this).width(boxwidth);

$(this).height(boxwidth / $(this).width() * $(this).height());

}

})

$(obj + tr tr).each(function () {

var trimg = $(this).find('img');

if (trimg.length > 1) {

var trimgwidth = (boxwidth / trimg.length);

trimg.each(function () {

if ($(this).width() > trimgwidth) {

$(this).width(trimgwidth);

$(this).height(trimgwidth / $(this).width() * $(this).height());

}

});

}

})

}

$(window).load(function () {

redrawimage(.newpic);//可以是id,或者类 (要设置的范围)

});

</script>

更多信息请查看IT技术专栏

更多信息请查看技术文章
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:ios利用单例实现不同界面间的数据传输
下一篇:html中嵌入flv格式文件的代码
易贤网手机网站地址:js重置图片的高宽
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!