Possible Duplicate:
Addition is not working in JavaScript
In an attempt to learn some java script, I'm trying to build a simple system that adds values when buttons are clicked..
The following code works, but will only add the hardcoded value of +100, can anyone help me change this code so it adds the value nested in the id="add" button?
<html> <head> <title>Input tutorial</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script language="javascript"> $(function () { $("#add").click(function() { $("#total").val(parseInt($("#total").val()) + 100) }); }); </script> </head> <body> <input type="button" value="12" id="add"> <input type="button" value="14" id="total"> </body> </html> Any help would be great! Thank you.