1

这个问题中,我问,如何根据 div 的数量生成一种颜色的阴影。@DonJuwe 提出了一个完美的解决方案和演示:http: //jsbin.com/xakifequ/1/edit JSBin 中的源代码

但是,当我尝试使用 jsfiddle 或JSBin中的代码时,它就不起作用了。所以我从 JSBin 下载了源代码,打开了 .html 文件,我得到的是:下载时会发生什么

有人可以解释一下,为什么会这样?

4

2 回答 2

5

As per snapshot, You are using

<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>

Replace it with

<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script>

You are using protocol less Urls, i.e. //code.jquery.com/jquery-1.9.1.js, When you open a your html file like file:// then jQuery is not loaded thus desired result is not achieved.

However, if you test your html file like http://localhost/yourfile.html you will get the desired result.

Note: Use // instead of http:// when you want to inherit the protocol from the page

于 2014-03-14T07:12:37.673 回答
3

you missed http: in the jQuery source link. if you using online resource you should follow the url's protocol. Other wise browser will search it from local. in this way you just confused your browser... So only it happens... :D

you should use...

<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script>

instead of

<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>
于 2014-03-14T07:13:34.673 回答