Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#7267 closed bug (duplicate)

Problem with $("").css('width') when upgrading from Jquery 1.4.2 to 1.4.3

Reported by: [email protected] Owned by:
Priority: low Milestone: 1.5
Component: unfiled Version: 1.4.3
Keywords: css width inline definition Cc:
Blocked by: Blocking:


Maybe this problem is with other .css() parameters, but in my case, Jquery behaves really strange.

When I use 1.4.2, these both cases below return the same output, that is "700px". But when I use 1.4.3, only in the first case the result is "700px", in the second case the result is "0px"

FIRST CASE: var div = $('<div id=​"product_edit_text" style=​"width:​700px;​height:​300px;​background-color:​#fff">​ </div>​​'); console.log(div.css('width')); returns "700px" in both 1.4.2 and 1.4.3

SECOND CASE: var div = $('<div id=​"product_edit_text" style=​"width:​ 700px;​ height:​ 300px; background-color:​ rgb(255, 255, 255)​;​ ">​ </div>​'); console.log(div.css('width')); returns "700px" in 1.4.2, but "0px" in 1.4.3 - BUG ?!

Change History (3)

comment:1 Changed 12 years ago by addyosmani

Keywords: css width inline definition added
Priority: undecidedlow

All of the tests that I've run on your code are returning 0px for 1.4.3 and auto for 1.4.2. Live test case

Bare in mind that this doesn't just apply for the width value, it also applies to height, background-color etc.

Ideally, adding inline styles in this manner is strongly unrecommended as using class-names (or even correct CSS style definitions outside of the string would make your solution both work and be a lot more clean).

Last edited 12 years ago by addyosmani (previous) (diff)

comment:2 Changed 12 years ago by snover

Resolution: duplicate
Status: newclosed

The test code provided in the initial description is invalid, as it contains zero-width spaces.

comment:3 Changed 12 years ago by snover

Duplicate of #7225.

Note: See TracTickets for help on using tickets.