Created
April 23, 2014 21:49
-
-
Save schickm/11233636 to your computer and use it in GitHub Desktop.
Using multiple variables
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
<input type="text" name="message"> | |
<button type="button" class="show-message">Show The Message...</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 | |
$(".show-message").click(function() { | |
// store value of the input a variable | |
var inputValue = $("input[name='message'").val(); | |
// store the static greeting + what we put in the variable above | |
var greeting = "A message for you:" + inputValue; | |
// and show the full greeting | |
alert( greeting ); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment