[英]How do I make this JavaScript work on my local machine?
The code I have below works if it's on my server but when viewed on my local machine it gives me the following errors: 我下面的代码如果在我的服务器上,但在本地计算机上查看时,它会产生以下错误:
ReferenceError: jQuery is not defined
$(document).ready(function() {
default.html (line 24)
ReferenceError: $ is not defined
$(document).ready(function() {
default.html (line 12)
ReferenceError: $ is not defined
$(document).ready(function() {
CODE: 码:
<script src="//code.jquery.com/jquery-latest.min.js"></script>
<link rel="stylesheet" href="slider/site/style.css">
<script type="text/javascript" src="slider/src/unslider.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var unslider = $('.container').unslider();
$('.arrow').click(function() {
var fn = this.className.split(' ')[1];
// Either do unslider.data('unslider').next() or .prev() depending on the className
unslider.data('unslider')[fn]();
});
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$('.line1').fadeIn(7000);
$('#slide2').delay(1000).fadeIn(3200);
$('#slide3').delay(1800).fadeIn(3200);
$('.line4').delay(4000).fadeIn(3500);
});
</script>
Your script tag is probably giving your browser trouble. 您的脚本标记可能会给浏览器带来麻烦。 Replace
"//code.jquery.com/jquery-latest.min.js"
with "http://code.jquery.com/jquery-latest.min.js"
and it should then work. 将
"//code.jquery.com/jquery-latest.min.js"
替换为"http://code.jquery.com/jquery-latest.min.js"
,它应该可以工作。
Replace 更换
<script src="//code.jquery.com/jquery-latest.min.js"></script>
with 同
<script src="code.jquery.com/jquery-latest.min.js"></script>
Your code couldn't find jquery. 你的代码找不到jquery。
添加http
到
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
this will do the trick 这将成功
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
//code.jquery.com/jquery-latest.min.js
this is pointing to find jQuery in the local server but the script is not available in the local server so chnage this to http://code.jquery.com/jquery-latest.min.js"
//code.jquery.com/jquery-latest.min.js
这指向在本地服务器中找到jQuery,但脚本在本地服务器中不可用,所以请输入http://code.jquery.com/jquery-latest.min.js"
You could have also downloaded the latest version and placed it in a js
folder under your docroot. 您也可以下载最新版本并将其放在docroot下的
js
文件夹中。 Then you could have accessed it with: 然后你可以通过以下方式访问它:
<script src="js/jquery-latest.min.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.