为什么jQuery在我的家用(本地)计算机上不起作用? [英] Why jQuery does not work on my home (local) machine?

查看:68
本文介绍了为什么jQuery在我的家用(本地)计算机上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题不是关于为什么我编写的特定jQuery不能正常工作,因为它根本没有jQuery正常工作.我什至没有直接从W3 Schools等地方复制的工作示例.

My question isn't so much about why a specific bit of jQuery I've written isn't working as it is about no jQuery at all is working; not even working examples I've copied directly from places like W3 Schools.

我在软件开发工作中不时使用jQuery,尽管我绝不是专家,但我对此非常熟悉.我第一次尝试在家庭项目中使用jQuery,无论我做什么,都无法使用.我在下面提供的示例就像我能想到的一样简单,甚至无法正常工作.

I use jQuery from time to time in my software development job and while I am by no means an expert, I am pretty familiar with it. For the first time I am trying to use jQuery in a home project and no matter what I do, none of it will work. The example I've included below is about as simple as I can think of, and even it will not work.

<!DOCTYPE HTML>
<html>
<head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
<div>
    <p>Old Stuff</p>
</div>
<script type="text/javascript">
   $('p').text('New Stuff');
</script>
</body>
</html>

这可能是什么问题?

推荐答案

代码正常.

该脚本未下载,因为您可能未在部署代码,因此浏览器将默认使用file://协议.

The script is not downloading because, as you probably are not deploying the code, the browser will default to the file:// protocol.

要解决此问题,请在脚本标记处添加http::

To solve it, add the http: at the script tag:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js">
                                                                           </script>

这篇关于为什么jQuery在我的家用(本地)计算机上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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