Adding Numbers in JavaScript

  1. <input type="text" id="textBox1"/><br/>  
  2. <input type="text" id="textBox2"/><br/>  
  3. <input type="button" value="ADD" id="addNumbers"/>  
  1. var tempVariable ='';  
  2. $("#addNumbers").click(function(){  
  3. var a = $("#textBox1").val();  
  4.     var b = $("#textBox2").val();  
  5.     tempVariable = parseInt(a)+parseInt(b);  
  6. alert(tempVariable);  
  7. });  
For the demo you can check the fiddle below:

http://jsfiddle.net/SurajMindfire/t8kzo7k0/

Here the parseInt does the trick, try now adding without parseInt then see the difference.

This will be of sure help I hope.
Thanks