javascript increment counter onclick

Solutions on MaxInterview for javascript increment counter onclick by the best coders in the world

showing results for - "javascript increment counter onclick"
Daniele
31 Jan 2021
1// Example implementation:
2function incrementValue()
3{
4    var value = parseInt(document.getElementById('number').value, 10);
5    value = isNaN(value) ? 0 : value;
6    value++;
7    document.getElementById('number').value = value;
8}
9
10/* Example Html:
11<form>
12   <input type="text" id="number" value="0"/>
13   <input type="button" onclick="incrementValue()" value="Increment Value" />
14</form>
15*/