如何使用jquery设置高度,宽度到图像

有没有办法使用jquery设置图像的高度和宽度? 以下是我的代码

var img = new Image(); // Create image $(img).load(function(){ imgdiv.append(this); }).error(function () { $('#adsloder').remove(); }).attr({ id: val.ADV_ID, src: val.ADV_SRC, title: val.ADV_TITLE, alt: val.ADV_ALT }); 

谢谢。

你可以调用.height()和.width() setter:

 var img = new Image(); // Create image $(img).load(function(){ imgdiv.append(this); }).error(function () { $('#adsloder').remove(); }).attr({ id: val.ADV_ID, src: val.ADV_SRC, title: val.ADV_TITLE, alt: val.ADV_ALT }).height(100).width(100); 
 $(".img1").css('height','10'); $(".img1").css('width','10'); 

要么

 $(".img1").attr('height','10'); $(".img1").attr('width','10'); 

如果图像在

 $('div.myGallery > img').css({ 'height': '10px', 'width': '10px' });