开发者

jQuery height() width()

开发者 https://www.devze.com 2022-12-26 23:48 出处:网络
I have an image on the page: <img id=\"foobar\" src=\"emptySpace.gif\" /> The image 开发者_如何学Gohas an absolute position of left: 0 and top: 0 in a .css file.

I have an image on the page:

<img id="foobar" src="emptySpace.gif" />

The image 开发者_如何学Gohas an absolute position of left: 0 and top: 0 in a .css file.

When I try this in JavaScript onmouseover, the height and width don't change. What am I missing?

var image = jQuery("#foobar");
image.height(500).width(500);

What gives?


Are you sure that code is being run - that the function is indeed being called on mouseover?

You could also try using the css() method:

image.css({height:'500px',width:'500px'});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号