nyten Posted September 15, 2014 Share Posted September 15, 2014 Hi,does anyone know why this javascript-counter can not add any decimal numbers? <body onload="javascript:startCounter();"><script>function startCounter() { document.getElementById('counter').innerHTML = parseInt(document.getElementById('counter').innerHTML) + 1.4; setTimeout('startCounter()', 200);}</script><div id="counter">0</div> Thanks^^ Quote Link to comment Share on other sites More sharing options...
wolstech Posted September 16, 2014 Share Posted September 16, 2014 Use parseFloat instead of parseInt. Quote Link to comment Share on other sites More sharing options...
nyten Posted September 17, 2014 Author Share Posted September 17, 2014 Now that looks a lot betterthank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.