Ticket #4464 (closed bug: fixed)
IE cannot get width attribute of detached IMG element
| Reported by: | netCo | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.6 |
| Component: | attributes | Version: | 1.3.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
i have the following code:
htmltmp = '<div style="width: 1100px;"><img src="test.gif" width="300" id="testphoto" /></div>';
alert($('#testphoto', htmltmp).attr('width'));
the internet explorer shows "0" and the firefox shows the right "300".
internet explorer: 7.0.5730.13 firefox: 3.0.8
Change History
comment:1 Changed 3 years ago by dmethvin
- Status changed from new to open
- Summary changed from internet explorer can't work with context to IE cannot get width attribute of detached IMG element
comment:2 Changed 2 years ago by dmethvin
- Keywords context removed
- Component changed from core to attributes
- Milestone changed from 1.4 to 1.6
This may be fixed by the attr rewrite in 1.6; need to check once that's landed.
comment:3 Changed 2 years ago by timmywil
- Status changed from open to closed
- Resolution set to fixed
This bug was a little more complex than that and actually still required a special call in IE, but is fixed. Was related to #5413. http://jsfiddle.net/timmywil/4HQtq/6/
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

http://jsfiddle.net/dmethvin/4HQtq/
Confirmed, but only occurs in IE with image elements not attached to the document. The problem is unrelated to context, it is due to the fact that jQuery prefers the image's .width property to its width attribute.