how to add two number using jqueryu 1

how to add two number using jqueryu

var a=parseInt($("#d1").val());
var b=parseInt($("#d2").val());
var sum=a+b;
alert($(sum));

Here is what the above code is Doing:
1. It is taking the value of the input field with id d1 and storing it in a variable a.
2. It is taking the value of the input field with id d2 and storing it in a variable b.
3. It is adding the values of a and b and storing it in a variable sum.
4. It is displaying the value of sum in an alert box.

Similar Posts