我正在尝试编写一个简单的代码,如下所示:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" />
<script>
$("#submitQuery").click(function() {
alert("Hola!!");
});
</script>
</head>
<body>
<label for="geo_location"> Enter location here: </label>
<input id="geo_location" type="text" name="geo_location" required />
<button id="submitQuery">Find out</button>
<div id="test"></div>
</body>
</html>
但是,单击该按钮不会执行任何操作。我在哪里错了?
答案 0 :(得分:3)
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" /> </script>
<script>
$(function(){
$("#submitQuery").click(function() {
alert("Hola!");
});
});
</script>
试试这个......你错过了准备好的功能..