Codey93 Codey93 - 1 year ago 78
HTML Question

Javascript, div on click multiple numbers in input field

I'm trying to create a

to modify the number in my input field.


<input value="0">

And then a simple button or div with a
click function.

<button>Add +10</button>

After clicking on the button:

<input value="10">

Does someone have a place I can read and learn to create this, or any tips to get me started. I know very little
, but I wish to learn.

Answer Source

You can try this

<input value="0" id="id">

give a id to input field

on button click call a function

<button onclick="myFunction()">Add +10</button>

    function myFunction() {
        document.getElementById("id").value = parseInt(document.getElementById("id").value) +10;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download