Ticket #7267 (closed bug: duplicate)
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: |
Description
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 3 years ago by addyosmani
- Keywords css width inline definition added
- Priority changed from undecided to low
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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