What width do you mean? If you mean the width of the element <div>
, there is a handy function that does exactly what you need. Play with some of them:
$('#foo').width();
$('#foo').innerWidth();
$('#foo').outerWidth();
As for finding the width
hidden element, I usually do this dirty trick:
var zIndex = $('#foo').css('z-index');
$('#foo').css('z-index', '-10');
$('#foo').css('position', 'absolute');
$('#foo').css('display', 'block');
var fooWidth = $('#foo').width();
$('#foo').css('display', 'none');
$('#foo').css('z-index', zIndex);
There should be an easier way though ...
source
share