Bug Tracker

Opened 14 years ago

Closed 12 years ago

Last modified 11 years ago

#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:
Blocked by: Blocking:


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 (5)

comment:1 Changed 12 years ago by dmethvin

Status: newopen
Summary: internet explorer can't work with contextIE cannot get width attribute of detached IMG element


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.

comment:2 Changed 12 years ago by dmethvin

Component: coreattributes
Keywords: context removed
Milestone: 1.41.6

This may be fixed by the attr rewrite in 1.6; need to check once that's landed.

comment:3 Changed 12 years ago by timmywil

Resolution: fixed
Status: openclosed

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/

comment:4 Changed 11 years ago by [email protected]

timmywil, so what was the special call required in IE? I'm experiencing the same issue, but jQuery 1.6 is not an option for me. I need to use 1.3.2.

comment:5 Changed 11 years ago by timmywil

You can do getAttribute('width', 2)

Note: See TracTickets for help on using tickets.