Addition of two numbers with java script

In this article I am going to show how to add 2 numeric numbers using java script:

<head runat="server">
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
        $(function() {
            $('#btnAdd').click(function() {
                var value1 = $('#txtFirstNumber').val();
                var value2 = $('#txtSecondNumber').val();
                var sum = parseInt(value1, 10) + parseInt(value2, 10);
    <form id="form1" runat="server">
    First Number :<input id="txtFirstNumber" type="text" /><br />
    Second Number:<input id="txtSecondNumber" type="text" />
    <input id="btnAdd" type="button" value="Add"  />
    <br />
    <span id="msg"></span>

About Author

Written By Lavish Kumar

Based out of New York, USA, Lavish Kumar is a full stack web developer by profession and founder of Striving Programmers, a trusted community for developers that offers a wealth of articles and forums to assist individuals with improving their software development skills.

Leave your comment
10/23/2014 4:36 AM
10/23/2014 4:36 AM