JavaScript > Arithmetic Operators

Division remainder in JavaScript

How to get the division remainder in JavaScript?

To get the division remainder number in JavaScript, we can follow this approach.

        function DivisionRemainder() {
            var a = document.getElementById("txtA").value;
            var b = document.getElementById("txtB").value;
            var result = parseInt(a) % parseInt(b);

    Enter two digit:
    <input type="text" id="txtA" name="txtA" />
    <input type="text" id="txtB" name="txtA" />
    <input type="button" name="btnDivisionRemainder" value="Submit" onclick="DivisionRemainder()" />

In the above code snippet, we have two textboxes. On click of button, we are calling the DivisionRemainder function that divide the numbers and shows remainder in the alert.


 Views: 5023 | Post Order: 16

Write for us

Hosting Recommendations