JavaScript > Arithmetic Operators

Increment in JavaScript

How to easily increment the number by one in JavaScript?

To increment number by one  in JavaScript, we can follow this approach.

        function Increment() {
            var a = parseInt(document.getElementById("txtA").value);
    Enter two digit:
    <input type="text" id="txtA" name="txtA" />
    <input type="button" name="btnIncrement" value="Submit" onclick="Increment()" />

In the above code snippet, we have One textbox. On click of button, we are calling the Increment function that increases the enterd number by one and show result in the alert.


 Views: 4732 | Post Order: 17

Write for us

Hosting Recommendations