Skip to content

Instantly share code, notes, and snippets.

@tsongas
Last active November 2, 2018 01:39
Show Gist options
  • Save tsongas/c8954167a4eb177fec9f1d84f244805b to your computer and use it in GitHub Desktop.
Save tsongas/c8954167a4eb177fec9f1d84f244805b to your computer and use it in GitHub Desktop.
jQuery.submit() example
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form id="target" action="destination.html">
<input type="text" value="Hello there">
<input type="submit" value="Go">
</form>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script>
$("#target").submit(function(event) {
event.preventDefault();
alert("Handler for .submit() called.");
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment