I have some code below:
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>StarTrackr!</title>
<script src="../../lib/jquery-1.7.1.min.js" type="text/javascript"
charset="utf-8"></script>
<script type="text/javascript">
$(document).ready(function () {
$('div').load('1.htm');
// The above function does work
$("#testform").submit(function () {
//Code after form submitted and this does not fire
alert("hi");
});
});
</script>
</head>
<body>
<div></div>
<form id="testform">Email:
<input type="text" name="email" />
<br />First Name:
<input type="text" name="fname" />
<br />Last Name:
<input type="text" name="lname" />
<br />
<input type="button" name="submit" id="submit" value="Submit" />
</form>
</body>
</html>
When I click on the submit button, the alert (hi) should pop-up but it does not. Does anyone know why? Assume the Jquery library is loaded correctly
Thanks,
Jim
The
inputneeds to havetype="submit", nottype="button".