duanbi6522 2013-08-30 09:28
浏览 77
已采纳

JavaScript可以设置高度,宽度等属性吗? [关闭]

I have a image that is stored in my files.

I want to view this image in 3 different sizes. So I use <img src> tag and define different height & width 3 times.

It was working perfectly fine when I was just echoing it. Now I want to view this in a slider, and I have add JavaScript code in it.

Its working fine for 'Thumb image' because it has <img src> tag with it, but small image and large image doesn't have <img src> tag and I am unable to understand how to resize image in both 'smallimage:' &'largeimage:'.

I don't know much about JavaScript. I just copied JavaScript code from somewhere else.

<link rel="stylesheet" href="css/jquery.jqzoom.css" type="text/css">
<script type="text/javascript">

    $(document).ready(function() {
        $('.jqzoom').jqzoom({
            zoomType: 'innerzoom',
            preloadImages: false,
            alwaysOn:false
        });
    });
</script>


<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
    <td align="right" valign="top" ><div class="clearfix" style="margin-left:-30px;">
        <a href="images/imgProd2/bracelets_Diamond.png" class="jqzoom" rel='gal1'  title="triumph" >         
            <img src='<?php echo $single_image_query_fetch['images']; ?>' height='261' width='325'  
                title='triumph'  style='border: 4px solid #666;'>            
        </a>
        </div>
        <br/>

      <!-------------------------------- Images Part is strating from here ------------------------->

        <div class="clearfix" style="margin-left:-30px; margin-top:-10px;" >
            <ul id="thumblist" class="clearfix" >

                $image_query = "select * from product_images where product_id=$id";
                $image_query_run = mysql_query($image_query);
                while( $image_query_fetch = mysql_fetch_array($image_query_run)) {

                    //Thumb                 
                    $thumb_image =
                        "<img src=http://localhost/cms/". 
                                $image_query_fetch['images'] ." height='80' width='100' alt=\"\" />";


                    //large
                    $big_image = "<img src=http://localhost/cms/". 
                            $image_query_fetch['images'] ." height='1024' width='1280' alt=\""/>";
                            $image_fetch[1]= $big_image;

                    //small                                 
                    $small_image = "<img src=http://localhost/cms/". 
                                    $image_query_fetch['images'] ." height='261' width='325' alt=\"\" />";
                <li>
                <a  href='javascript:void(0);' rel="{gallery: 'gal1', 
                                                        smallimage: 'images/imgProd2/Bracelet_Silver.png',
                                                        largeimage: 'images/imgProd2/bracelets_Diamond.png'}">
                        <img src='<?php echo $image_fetch[0]; ?>' height='80' width='100' >
                    </a>
            </li>
}

In <li> i want to define sizes for smallimage and largeimage. Kindly tell me how to do it.

  • 写回答

2条回答 默认 最新

  • douzhi9478 2013-08-30 09:39
    关注

    Yes you can.

    For height :

    $(".smallimage").height(100);
    

    For width :

    $(".smallimage").width(150);
    

    Change 100 and 150 to your value or a dynamic one...

    Cheers

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题