我在下面有一些代码:
<!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>
当我单击提交按钮时,应该会弹出警报 (hi) 但它不会。有谁知道为什么?假设 Jquery 库已正确加载
谢谢,吉姆