#11041 closed bug (duplicate)
$('#elem').css('width') in percentage in jquery 1.5.2 vs 1.7.1
Reported by: | strikernl2 | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I'm not actually sure that this is a bug or just intended changed behaviour between jQuery 1.5.2 and 1.6 (and thus 1.7.1), but here goes.
I'm in the process of upgrading a web application from jQuery 1.5.2 to 1.7.1. In jQuery 1.5.2, it was possible to get the percentage CSS value of an element using $('#elem').css('width'), if the element was inside another hidden element.
To be clear, I need the CSS value in PERCENTS and I don't know beforehand whether it will be in percents, or px, or em, or whatever.
For a simple test case, see here: http://jsfiddle.net/strikernl/y3P3A/
It seemed to work in 1.5.2, then no longer in 1.7.1. I added 1.6 in the test just to see if that still worked, and it didn't, so it broke somewhere between 1.5.2 and 1.6 I guess.
Change History (7)
comment:1 Changed 11 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 Changed 11 years ago by
comment:3 Changed 11 years ago by
Sorry, I did look, could not find a matching ticket however. Thanks!
comment:4 Changed 10 years ago by
This is not a duplicate ticket. This needs to be fixed. It is returning pixels instead of percentage. The linked ticket is for a separate issue, when div is inside a hidden element
comment:5 follow-up: 6 Changed 10 years ago by
.css()
uses the browser's .getComputedStyle()
which is supposed to get the computed styles in pixels, if not for some bug cases in various implementations. Fixing that is beyond the capability of jQuery, we don't have the information. This whole mess is under discussion in the W3C lists if you want to follow them.
Ref: http://lists.w3.org/Archives/Public/www-style/2012Jul/0282.html
comment:6 follow-up: 7 Changed 10 years ago by
That is very interesting. So you are saying that if I have a div whose width is 100% I cannot get that information back from JQuery? but selecting that div and running .width() or .css()?
comment:7 Changed 10 years ago by
Replying to [email protected]…:
That is very interesting. So you are saying that if I have a div whose width is 100% I cannot get that information back from JQuery? but selecting that div and running .width() or .css()?
SORRY! Meant to say "That is very interesting. So you are saying that if I have a div whose width is 100% I cannot get that information back from JQuery by selecting that div and running .width() or .css()?"
Duplicate of #10782.