我无法让 jQuery 工作 [关闭]

2024-05-04

你好,我正在尝试一些 jQuery,但没有运气。正在写代码,什么都没有,什么都不起作用。所以我尝试了 w3schools 的一些 JQuery,但根本不起作用。 知道为什么我无法让它工作吗?

我的 html 头部有这个

 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>  

还是不行。

感谢任何帮助谢谢 米奇

<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").fadeIn();
$("#div2").fadeIn("slow");
$("#div3").fadeIn(3000);
});
});
</script>
</head>

<body>
<p>Demonstrate fadeIn() with different parameters.</p>
<button>Click to fade in boxes</button>
<br><br>
<div id="div1" style="width:80px;height:80px;display:none;background-color:red;"></div>        <br>
<div id="div2" style="width:80px;height:80px;display:none;background-color:green;">    </div><br>
<div id="div3" style="width:80px;height:80px;display:none;background-color:blue;">  </div>

</body>
</html>

将其复制到记事本中,保存它然后在 chrome 中运行它,当我按下按钮时什么也没有发生。

感谢所有提供帮助的人


这里的问题是您用来加载 jQuery 的相对 url 方案。由于我假设您正在本地加载 html 文件,因此您的页面方案是file://。当你使用以下方式加载 jQuery 时//作为源,它在本地文件系统上查找名为的文件夹ajax.googleapis.com。代替//在你的脚本标签中https://来解决你的问题。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

我无法让 jQuery 工作 [关闭] 的相关文章

随机推荐