Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#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:


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:


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 11 years ago by timmywil

Owner: set to Ivellina
Status: newpending

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.

comment:2 Changed 11 years ago by Ivellina

Status: pendingnew


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.


Last edited 11 years ago by Ivellina (previous) (diff)

comment:3 Changed 11 years ago by timmywil

Keywords: needsreview added
Status: newopen

After some investigation, it seems we are always using the computed in jQuery.css. This may be intended behavior.

Last edited 11 years ago by timmywil (previous) (diff)

comment:4 Changed 11 years ago by Ivellina

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 11 years ago by timmywil

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 11 years ago by Ivellina

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 11 years ago by timmywil

Component: unfiledcss
Priority: undecidedlow

comment:8 Changed 11 years ago by dmethvin

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 11 years ago by timmywil

Keywords: needsreview removed
Resolution: duplicate
Status: openclosed

comment:10 Changed 11 years ago by timmywil

Duplicate of #7486.

Note: See TracTickets for help on using tickets.