Pretty simple task: using jquery I need to calculate the width of an input before the input is visible on the screen.
http://jsfiddle.net/ajbeaven/mKQx9/
Here is the code for convenience:
<div style="display:none;">
<input />
</div>
<script type="text/javascript">
$(function () {
alert($('input').width());
$('div').show();
});
</script>
Alert always shows 0
How do I calculate width without having to forcibly make the element visible, calculate the width, then hide them again?