Reputation: 2835
html:
<img alt="test" width="100" height="100">
javascript:
alert($('img').height());
On most browsers (chrome), the alert displays "100" as one would expect. On firefox, it does not. It "helpfully" converts the img into something that looks like:
<div>test</div>
.. and reports the height of that - "19" in my case. I can work around the problem by assigning a placeholder src right before I check the height, and that works ok.
I didn't really forget the src attribute, rather I am in the process of computing it client-side.
I guess my question is - is there some way to disable this firefox "helpfulness"?
Upvotes: 2
Views: 1024
Reputation: 47667
Yes, you can assign display: inline-block
to your image - http://jsfiddle.net/2N854/1/ and FF will behave :)
Upvotes: 4
Reputation: 15472
This isn't exactly an answer to your question, but couldn't you just use $('img').attr('height')
instead?
Upvotes: -1