网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 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>
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/22 7:28:33