-1

我一直试图让一个简单的 jQuery 示例工作几个小时。

<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("p").toggle();
  });
});
</script>
</head>
<body>

<button>Toggle</button>
<p>This is a paragraph with little content.</p>
<p>This is another small paragraph.</p>
</body>
</html>

我似乎无法加载 jQuery。

4

4 回答 4

4

probably, you are running your html locally

try using http: in your jquery url like this -

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
于 2013-05-29T08:52:14.753 回答
0

您的脚本网址上似乎缺少http:前缀:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
于 2013-05-29T08:53:20.050 回答
0

http:当您包含javascript时放置:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
于 2013-05-29T08:53:20.117 回答
0

更新这行代码

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

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

https:为 src添加了

于 2013-05-29T08:53:29.003 回答