我在我的网站上注意到 jQuery 停止工作,但我在控制台上没有收到任何错误。 我一直在尝试使用非常基本的代码对其进行测试,但 jquery 库仍然加载良好,javascript 代码有效但 jQuery 无效。 我在两台不同的计算机上使用 Chrome 和 Internet Explorer 对其进行了测试。 有人可以指出我寻找这个问题的方向吗?
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"/>
<script>
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<h1>JQuery</h1>
<p>hide me please</p>
<p id="demo">demo</p>
<script>
document.getElementById("demo").innerHTML = "My First JavaScript";
</script>
</body>
</html>
最佳答案
尝试使用
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
代替
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"/>
让我们知道它是否解决了问题。 <script>
标签不应自闭。
关于javascript - JQuery 在没有任何错误消息的情况下停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28646775/