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
From stackoverflow
-
$(window).load( function() { alert($('img').width()); } );
This will work: Test case. Basically it will wait until images load before executing the code (when the ready function fires the document has been fully loaded but images haven't).
Sarfraz : @Andreas Bonini: Perfect, load never popped up in my mind, Thanks :)
0 comments:
Post a Comment