Bug Tracker

Ticket #7267 (closed bug: duplicate)

Opened 4 years ago

Last modified 4 years ago

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

Reported by: frodik.cz@… Owned by:
Priority: low Milestone: 1.5
Component: unfiled Version: 1.4.3
Keywords: css width inline definition Cc:
Blocking: Blocked by:


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

comment:1 Changed 4 years ago by addyosmani

  • Keywords css width inline definition added
  • Priority changed from undecided to low

All of the tests that I've run on your code are returning 0px for 1.4.3 and auto for 1.4.2. 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).

Version 0, edited 4 years ago by addyosmani (next)

comment:2 Changed 4 years ago by snover

  • Status changed from new to closed
  • Resolution set to duplicate

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

comment:3 Changed 4 years ago by snover

Duplicate of #7225.

Note: See TracTickets for help on using tickets.