I want to be able to calculate the width, in pixels, of an element that has the width css property set to 'auto'
.
I have tried element.style.width
but didn't work because it returned 'auto'
. I notices that the jQuery function width()
returns the length in px, but I cannot use jQuery to solve this, because it is not available in my page. So, does anybody know an equivalent method for jQuery width()
?
Thanks.
It basically comes down to .offsetWidth
, but the jQuery code is a little more complicated due to cross-browser differences.