JQuery .css() returning 100% as 100px

css, html, javascript, jquery

Solution

I think a possible cause is the container of the element being hidden at the moment you're trying to obtain the dimensions.

I had a similar situation with nested divs and tables.

See the following fiddle where I managed to reproduce the behavior:

http://jsfiddle.net/36yvb/

I still think it's a bug in jQuery returning a percentage as an integer number (without the `%` sign) when not being able to actually compute the dimensions of the element. Change the width of `#another-cell` (expressed in %) and see it return the same value without the `%` sign when the table is hidden.

Problem

``` <style> .info{ width:94%; } </style> ``` Now doing like this using JQuery ``` $('.info').css('width'); ``` returns 94px rather than the equivalent value in pixles (500px in my case.) if i set the width in css as 105% , JQuery would return it as 105px . The height and width of the parent container is 600px and 500px respectively.

Original source