<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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With