JavaScript可以设置高度、宽度等属性


Can JavaScript set attributes like height, width?

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

我想用三种不同的尺寸观看这张图片。所以我使用CCD_ 1标签并定义不同的高度&宽度3倍。

当我只是回显它的时候,它运行得很好。现在我想在滑块中查看它,我已经在其中添加了JavaScript代码。

它适用于"Thumb image",因为它带有<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的大小。请告诉我怎么做。

可以。

对于高度

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

宽度

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

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

干杯

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

我不知道是largeimage和smallimage,还是classes或id,所以你必须自己指定,假设你知道如何做到这一点。。。因为高度和宽度属性显示在jquery文档中。不仅如此,这个问题在这里肯定已经被问了100多次了。