JQuery: Problem in getting element's width in Chrome

Posted by Sarfraz on Stack Overflow See other posts from Stack Overflow or by Sarfraz
Published on 2010-03-13T19:29:18Z Indexed on 2010/03/13 19:35 UTC
Read the original article Hit count: 500

Filed under:
|
|
|
|

Hello,

Suppose I have this image:

<img src="images/01.jpg" border="0" rel="shadow" />

Then with JQuery, I get its width using:

$('[rel="shadow"]').width();

Firefox and IE report correct dimensions of the image eg 140px while Chrome reports 0. How to solve this problem?

Note:

I don't want to set explicit width for images eg:

<img src="images/01.jpg" border="0" rel="shadow" width="140" />

So, how to get width in cross-browser way which is not defined in width attribute of elements?

Thanks

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript