我正在尝试使用 jQuery,但由于某种原因,当我单击按钮时没有任何反应。我尝试以多种方式操作代码,但仍然没有任何反应
我使用的是 Firefox,JavaScript 运行良好。
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<style>
body {
background-color:royalblue;
margin:0px;
}
#div_header {
background-color:black;
height:200px;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$("button").click(function() {
$("#div_header").hide();
});
});
</script>
</head>
<body>
<div id="div_header">
<button type="button">Click me!</button>
</div>
</body>
</html>
最佳答案
脚本源值不正确。将其更改为
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
关于jquery - 正在学习 jQuery,但什么也没发生?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14651411/