I've got the following onChange code. It updates my div1 with the value. The value is a numeric value and I would like to round it so that there is no decimal point. Can anyone tell me how this can be done?

So for example value 12.987654321 will be 13

onChange="document.getElementById('div1').innerHTML=this.value"
有帮助吗?

解决方案

There is a Math.round function you could use like this (otherwise your code looks fine to me):

onChange="document.getElementById('div1').innerHTML=Math.round(+this.value)"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top