Modify ↓
Ticket #5728 (closed bug: duplicate)
Cannot access IMG attributes (height, width) in IE if parent is null
| Reported by: | mazniak | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.4 |
| Component: | attributes | Version: | 1.3.2 |
| Keywords: | dom, attributes, ie | Cc: | |
| Blocking: | Blocked by: |
Description
On a about:blank page, load jQuery and run the following commands:
foo = $("<img id='foo' src=' http://www.google.com/images/srpr/logo1w.png'>"); foo.attr("height", 111); console.log(foo.attr("height")); does *not* work in IE8 console.log(foo.get(0).getAttribute("height")); does return 111
The 'attr()' method does not return the expected values in IE8, but it does so in Firefox and Safari. This can be remedied by appending the IMG element to a DOM element (like 'html' or 'body') and calling 'attr()' again.
Attachments
Change History
Changed 3 years ago by mazniak
-
attachment
index.html
added
comment:1 Changed 3 years ago by dmethvin
- Component changed from unfiled to attributes
- Summary changed from Cannot access some IMG attributes (height, width) while IMG element’s parent is null to Cannot access IMG attributes (height, width) in IE if parent is null
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

A test case for reproducing the bug.