#8741 closed bug (duplicate)
.css("height") returns computed height
Reported by: | Ivellina | Owned by: | Ivellina |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | css | Version: | 1.5.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
As of version 1.5.1 and 1.5.2 .css("height") returns computed height instead of the style property height. For example :
<table id="anId" style="height: 200px">...
accessed by:
$("anId").css("height")
returns the real table size instead of 200px.
It works fine in version 1.3.2. The problem is always reproducible on Firefox 3.0.5 and IE 8 on Windows XP.
Change History (10)
comment:1 Changed 12 years ago by
Owner: | set to Ivellina |
---|---|
Status: | new → pending |
comment:2 Changed 12 years ago by
Status: | pending → new |
---|
Hi,
Thanks for your quick response.
I made an example to show you the problem we have. http://jsfiddle.net/FTjzm/1/
If you change the version to 1.3.2 you will see that it works correctly.
Ivelina
comment:3 Changed 12 years ago by
Keywords: | needsreview added |
---|---|
Status: | new → open |
Version: | 1.5.1 → 1.5.2 |
After some investigation, it seems we are always using the computed in jQuery.css. This may be intended behavior.
comment:4 Changed 12 years ago by
If this is the intended behavior can you point me to the method I have to use in order to get the css height attribute?
comment:5 Changed 12 years ago by
You will be able to use prop in 1.6, but for now you can use raw js. http://jsfiddle.net/timmywil/FTjzm/6/ Nevertheless, this still needs review as to whether always getting the computed value is intended behavior because I can't say for sure myself.
comment:6 Changed 12 years ago by
Thank you for your suggestion. It works for us and we will apply it as a fix until we are waiting for version 1.6.
comment:7 Changed 12 years ago by
Component: | unfiled → css |
---|---|
Priority: | undecided → low |
comment:8 Changed 12 years ago by
Yes it seems logical that .height()
should return the height in pixels and .css("height")
should return the non-computed CSS string (auto
, 20em
, etc.) for height. The problem is that other measurements (e.g., borderRightWidth
) don't have a way to get computed vs. non-computed values via the jQuery API. It would be a serious problem IMO to return non-computed values for those.
I know it's been discussed quite a bit in the past but we need to document and justify why it works this way in the docs if it's to stay this way.
comment:9 Changed 12 years ago by
Keywords: | needsreview removed |
---|---|
Resolution: | → duplicate |
Status: | open → closed |
I created a test case based on your description and was unable to reproduce your issue. I checked in IE8. http://jsfiddle.net/timmywil/YxTn2/. Please provide a test case on jsfiddle or update mine to demonstrate the problem.