How to get element width in pixels (px)? jQuery always returns value in percent (pct).
HTML
<span class="myElement"></span>
CSS
.myElement {
float: left;
width: 100%;
height: 100%;
}
JavaScript
$('span.myElement').css('width') // returns '100%'
$('span.myElement').width() // returns '100'
Thanks!
See Question&Answers more detail:os