Last active
August 29, 2015 14:00
-
-
Save schickm/11233212 to your computer and use it in GitHub Desktop.
Adding two values together
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p> | |
<input type="text" name="input-a"> | |
<span>+</span> | |
<input type="text" name="input-b"> | |
<p> | |
<button type="button" class="calculate">Add them up</button> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> | |
<script type="text/javascript"> | |
// wait for someone to click on a button | |
$(".calculate").click(function() { | |
// get the value of the input, and show it in a dialog | |
var a = parseFloat( $("input[name='input-a'").val() ); | |
var b = parseFloat( $("input[name='input-b'").val() ); | |
alert( a + b ); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment