- <input type="text" id="textBox1"/><br/>
- <input type="text" id="textBox2"/><br/>
- <input type="button" value="ADD" id="addNumbers"/>
- var tempVariable ='';
- $("#addNumbers").click(function(){
- var a = $("#textBox1").val();
- var b = $("#textBox2").val();
- tempVariable = parseInt(a)+parseInt(b);
- alert(tempVariable);
- });
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