For example: Copy code The code is as follows: <br>var elem = document.getElementById('demo'), <br>width = elem.style.width; <br>alert( parseInt(width));// 24 <br> But what if the css value is like this: Copy Code The code is as follows: var elem = document.getElementById('demo'), <br>opacity = elem.style.opacity; <br>alert(parseInt(opacity));// 0 <br> 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: Copy code The code is as follows: <br>var elem = document.getElementById('demo'), <br>opacity = elem.style.opacity; <br>alert(parseFloat(opacity));// 0.5 <br> </div> <br>What’s the difference between the two? <br><br>parseInt() returns an integer <br>parseFloat() returns a floating point number <br><br>Learn more about <a href="http://www.jb51.net/w3school/js/jsref_parseInt.htm" target="_blank">parseInt</a> and <a href="http://www.jb51.net/w3school/js/jsref_parseFloat.htm" target="_blank">parseFloat</a>