我有一个第三方脚本是设置图像的宽度和高度,但对于我的生活,我无法弄清楚它是如何做到这一点。它可能来自数据库或者一个类,但是它们有很多。如何使用jQuery更改属性?
的HTML看起来是这样的:
<img src="..." width="30px" height="30px">
使用jQuery,我怎么可以改变高度和宽度值?
我猜它是这样的:
$("..[$width="]").replace(
这里是元素的HTML:
<div id="prodThumbnails">
<table style="width: 641px;">
<tbody>
<tr>
<td align="right" style="vertical-align: middle;">
</td>
<td nowrap="nowrap" class="productPhotoThumbnailSection">
<a onclick="javascript:drawMainImage('0', '')" href="javascript:swapImage()">
<img height="30" width="30" border="0" title="" alt=""
src="images/products/85.png"/></a>
<a onclick="javascript:drawMainImage('1', '')" href="javascript:swapImage()"><img height="30" width="30" border="0" title="" alt=""
src="images/products/90.jpg"/></a>
<a onclick="javascript:drawMainImage('2', '')" href="javascript:swapImage()">
<img height="30" width="30" border="0" title="" alt="" src="images/products/92.jpg"/></a>
</td>
<td align="left" style="vertical-align: middle;">
</td>
</tr>
</tbody>
</table>
</div>
我试着这样做:
$(function() {
$("td.productPhotoThumbnailSection img").attr("width","64px");
$("td.productPhotoThumbnailSection img").attr("height","64px");
});
,但会将设置图像宽度和高度为0.
谢谢你,我在顶部更新了我的帖子,你认为它可以是什么? – sarmenhb 2009-11-25 02:16:46