我有一个简单的表单,有一个必填字段,我用于测试。我第一次点击提交时,警报按预期弹出,但在第一次之后永远不会弹出。我必须重新加载页面才能弹出显示。有人能帮助我理解为什么会这样吗?
提前致谢。 RD
代码:
<!DOCTYPE html>
<html>
<head>
<title>My Mobile Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/jquery.mobile.structure-1.3.1.css" />
<link rel="stylesheet" href="css/jquery.mobile.theme-1.3.1.css" />
<link rel="stylesheet" href="css/jquery.mobile-1.3.1.css" />
<script src="js/jquery.js"></script>
<script src="js/jquery.mobile-1.3.1.js"></script>
<script type="text/javascript">
$(document).ready(function ()
{
$('#addSpEvent').submit(function ()
{
alert("form submit clicked");
});
});
</script>
</head>
<body>
<div data-role="page" page-id="addSports">
<div data-role="header">
<h1>Header goes here</h1>
</div><!-- /header -->
<div data-role="content">
<form id="addSpEvent" action="addSports.html" method="post">
<div id="spevSched" data-role="fieldcontain" data-mini="true">
<label for="spevDate">Date</label>
<input id="spevDate" type="date" required />
<label for="spevLocation">Location</label>
<input id="spevLocation" type="text" />
<input id="addSpEvent" name="addSpEvent" type="submit" value="Add" />
</div>
</form>
</div><!-- /content -->
<div data-role="footer">
<h3>Footer goes here</h3>
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>