Skip to content

Instantly share code, notes, and snippets.

@schickm
Last active August 29, 2015 14:00
Show Gist options
  • Save schickm/11231866 to your computer and use it in GitHub Desktop.
Save schickm/11231866 to your computer and use it in GitHub Desktop.
Getting a value from an input using jQuery
<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() {
// get the value of the input, and show it in a dialog
alert( $("input[name='message'").val() );
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment