所以我有一个这样的表格和脚本:
$(document).ready(function() {
alert("ready");
$("#find_stuff").submit(function(event) {
event.preventDefault();
alert("Handler for .submit() called.");
});
});

<html>
<head>
<title>Meme</title>
<script src="js/main.js"></script>
</head>
<body>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous">
</script>
<!-- This is temp, we will put in another file later !-->
<form id="find_stuff">
<p>Thing I want</p><br>
<input type="text" name="things_needed">
<input type="submit" value="Submit">
</form>
</body>
</html>
&#13;
请记住,当我访问网站时,我确实看到了准备好的警报,但是当我点击表单上的提交时,它就会做任何事情。
答案 0 :(得分:-1)
$(document).ready(function(){
alert("ready");
$( "#find_stuff" ).submit(function( event ) {
event.preventDefault();
alert( "Handler for .submit() called." );
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<html>
<head>
<title>Meme</title>
<script src="js/main.js"></script>
</head>
<body>
<form id="find_stuff">
<p>Thing I want</p><br>
<input type="text" name="things_needed">
<input type="submit" value="Submit">
</form>
</body>
</html>