<script> <br>var elem = document.getElementById('demo'), <br>width = elem.style.width; <br>alert( parseInt(width));// 24 <br></script>
It is obvious that parseInt() will make an error, even if it is a value like '.5', if you change it to parseFloat(), you will get the correct result: