Modify ↓
Ticket #8388 (closed bug: fixed)
.css(prop) fails in IE for detached elements
| Reported by: | jaredjacobs@… | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | 1.next |
| Component: | css | Version: | 1.5.1 |
| Keywords: | needsreview | Cc: | |
| Blocking: | Blocked by: |
Description
This seems to be a regression introduced in 1.4.3 and still broken in 1.5.1. (1.4.2 does not have the bug.)
In most browsers:
$("<div/>").css("top", 10).css("top")
> "10px"
However, in IE (I tried IE 8):
$("<div/>").css("top", 10).css("top")
> null
even though:
$("<div/>").css("top", 10)[0].style.top
> "10px"
Change History
comment:2 Changed 2 years ago by rwaldron
- Priority changed from undecided to high
- Status changed from new to open
- Component changed from unfiled to manipulation
Confirmed.
comment:4 Changed 2 years ago by dmethvin
Most likely because it's getting the computed style and not the literal css string. I don't know if this is a reasonable request of the browser since top doesn't make a lot of sense on a disconnected element.
comment:5 Changed 2 years ago by john
- Component changed from manipulation to css
We should be checking to see if the node is disconnected and just using .style.top instead. Confirmed in bug triage.
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 workaround is attaching the element to the document:
$("<div/>").css("top", 10).appendTo("body").css("top") > "10px"P.S. Here's a jsfiddle demonstrating the problem (in IE): http://jsfiddle.net/qrXen/1/