JavaScript > Arithmetic Operators

Decrement in JavaScript

How to easily decrement the number by one in JavaScript?

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

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

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


 Views: 4130 | Post Order: 18

Write for us

Hosting Recommendations