我无法让jQuery工作 [英] I can't get jQuery to work

查看:67
本文介绍了我无法让jQuery工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试尝试一些jQuery,但一点都不走运.正在写代码,什么也没写,什么也没用.所以我尝试了w3schools的一些JQuery,但这甚至没有用. 知道为什么我不能使它工作吗?

Hi I am trying to try out some jQuery and having no luck at all. Was writing code and what not and nothing was working. So I tried some JQuery from w3schools and that didn't even work. Any idea why I cant get it to work?

我在html的头上有这个

I have this in the head of my html

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

仍然无法正常工作.

感谢您的任何帮助,谢谢 米奇

Grateful for any help Thanks Mikey

<!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中运行,当我按下按钮时什么也没发生.

Copied that into notepad, saved it then ran it in chrome, when I pressed the button nothing happened.

感谢所有提供帮助的人

推荐答案

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

The problem here is the scheme relative url that you are using to load jQuery. Since I assume you are loading the html file locally, your page's scheme is file://. When you go to load jQuery using // as the source it is looking on your local filesystem for a folder called ajax.googleapis.com. Replace // in your script tag with https:// to solve your problem.

这篇关于我无法让jQuery工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆