Side navigation
#12625 closed bug (duplicate)
Opened September 27, 2012 01:39PM UTC
Closed September 28, 2012 12:04PM UTC
Last modified September 28, 2012 07:40PM UTC
Different value from width() and css('width')
Reported by: | SSPPYY | Owned by: | SSPPYY |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | css | Version: | 1.8.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery return different value from width() and css('width') in Firefox 15.0.1 (IE9 and Chrome 22 is OK).
Example:
var select = $('<select style="width: 120px;"><option value="">X</option></select>');
select.css('width'); return 120px
select.width(); return 116
Tested version was 1.8.0 and 1.8.2.
This issue not present in version 1.6.2.
Attachments (0)
Change History (5)
Changed September 27, 2012 02:41PM UTC by comment:1
component: | unfiled → css |
---|---|
owner: | → SSPPYY |
status: | new → pending |
Changed September 28, 2012 05:35AM UTC by comment:2
status: | pending → new |
---|
Select DOM element was not append to any other element.
Here is test case with code:
Changed September 28, 2012 12:04PM UTC by comment:3
resolution: | → duplicate |
---|---|
status: | new → closed |
Duplicate of #12071.Two bits of advice:
1. Don't query style information on disconnected nodes. If the styles were applied due to an external stylesheet rather than inline, chrome would report nothing.
2. Use .css('width') if you want the width style value, use .width() if you want content width (not including padding or border, as is the case with select elements).
Changed September 28, 2012 06:13PM UTC by comment:4
OK but with older version no problem. I use 1.7.2 at now and i dont have any problem. When i switch to 1.8.0 and newer, crash all my design.
And what about back compatibility?
Changed September 28, 2012 07:40PM UTC by comment:5
This was by design. Either you can switch to .css('width'), stick with 1.7.2, or update your designs, but this isn't something we are going to revert.
I am unable to reproduce. http://jsbin.com/iyufoy/1/
Please provide a test case on http://jsfiddle.net or http://jsbin.com.