jQuery 无法在我的 Windows 8.1 64 位计算机上运行。是否存在导致该问题的已知问题?
已尝试过 CDN(Google、jQuery)和本地源,但都不起作用。我知道代码是正确的,因为我尝试了各种示例来验证,包括以前运行良好的旧代码以及此 YouTube 教程中的代码:
https://www.youtube.com/watch?v=VRnQOcVclS8
我也尝试过使用这个脚本源,但没有成功:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
如何测试:点击一个段落标签,它应该隐藏。单击 H1 标签,它应该打开或关闭。这些对我来说都不起作用。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Demo</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>Heading one</h1>
<p>This is just some text for heading 1</p>
<h1>Heading two</h1>
<p>This is just some text for heading 2</p>
<h1>Heading three</h1>
<p>This is just some text for heading 3</p>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("p").hide();
$("h1").click(function() {
$(this).next().slideToggle(300);
});
});
</script>
</html>
这些都不起作用。不知道发生了什么事。
更新
一些有用的评论者测试了我的代码,它似乎在他们的机器上运行良好,这确实有助于缩小问题范围。已经确定我的代码是好的。因此,在这一点上,对于任何愿意提供帮助的人,我正在寻找具体信息、“已知问题”或“陷阱”来解释为什么这对我不起作用。我怀疑它与 Window 8 或 Windows 8.1 有关,但我不知道它是什么。
最佳答案
改变
<script type="text/javascript" src="http"//code.jquery.com/jquery-1.8.0.min.js"></script>
至
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
关于javascript - jQuery 无法在 Windows 8 中的任何浏览器中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24318156/