Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#12625 closed bug (duplicate)

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:


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.

Change History (5)

comment:1 Changed 11 years ago by Timmy Willison

Component: unfiledcss
Owner: set to SSPPYY
Status: newpending

I am unable to reproduce. http://jsbin.com/iyufoy/1/

Please provide a test case on http://jsfiddle.net or http://jsbin.com.

comment:2 in reply to:  1 Changed 11 years ago by SSPPYY

Status: pendingnew

Select DOM element was not append to any other element.
Here is test case with code:

comment:3 Changed 11 years ago by mikesherov

Resolution: duplicate
Status: newclosed

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).

comment:4 Changed 11 years ago by SSPPYY

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?

comment:5 Changed 11 years ago by mikesherov

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.

Note: See TracTickets for help on using tickets.