<input type="button" value='click' onclick="show()">
<input id="inp" value='some text'>
<span id="mySpan" style="display: none"></span>
<script>
function show() {
mySpan.innerHTML = inp.value;
mySpan.style.display = 'inline';
var oh = mySpan.offsetWidth;
mySpan.style.display = 'none';
alert('offsetWidth = ' + oh);
}
</script>