Bug Tracker

Ticket #4464 (closed bug: fixed)

Opened 7 years ago

Last modified 4 years ago

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:


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


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 5 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 5 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/

comment:4 Changed 4 years ago by tjlawren@…

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 4 years ago by timmywil

You can do getAttribute('width', 2)

Note: See TracTickets for help on using tickets.