DEV Community

KarmaBlackshaw
KarmaBlackshaw

Posted on

Get input element value as number

For the following input element:

<input type="number" id="input">
Enter fullscreen mode Exit fullscreen mode

Instead of:

document.getElementById('inpupt').value 
// '12'
Enter fullscreen mode Exit fullscreen mode

You can do:

document.getElementById('inpupt').valueAsNumber 
// 12
Enter fullscreen mode Exit fullscreen mode

You can read more here

Top comments (0)