JavaScript可以设置高度,宽度等属性吗?

时间:2013-08-30 09:28:50

标签: php jquery html slider

我有一个存储在我的文件中的图像。

我想以3种不同的尺寸查看此图片。所以我使用<img src>标签并定义不同的高度和宽度。宽度3倍。

当我回应它时,它工作得非常好。现在我想在滑块中查看它,并在其中添加JavaScript代码。

它对“拇指图像”工作正常,因为它带有<img src>标记,但小图像和大图像没有<img src>标记,我无法理解如何调整图像大小两个'smallimage:' &'largeimage:'。

我对JavaScript知之甚少。我只是从其他地方复制了JavaScript代码。

<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>
}

<li>我想要定义smallimagelargeimage的尺寸。请告诉我该怎么做。

2 个答案:

答案 0 :(得分:1)

$("smallimage").css('height', 'num_here');
$("smallimage").css('width', 'num_here');

$("largeimage").css('height', 'num_here');
$("largeimage").css('width', 'num_here');

我不知道bigimage和smallimage或类或id是否因此你必须指定你自己假设你知道如何做...因为高度和宽度属性显示在jquery文档中。不仅如此,这个问题必须在这里被问过100次以上。

答案 1 :(得分:1)

是的,你可以。

身高

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

宽度

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

将100和150更改为您的值或动态值...

干杯