我的Javascript似乎不起作用

我的Javascript似乎不起作用,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我无法让Javascript正常工作。这三个文件夹都在同一个文件夹中。Chrome也需要一段时间才能打开,但Firefox是即时的。谢谢 我的HTML: 我的Javascript: $(document).ready(function(){ $('div').mouseenter(function(){ $(this).fadeTo(1000, 1); }); $('div').mouseleave(function(){ $(this)

我无法让Javascript正常工作。这三个文件夹都在同一个文件夹中。Chrome也需要一段时间才能打开,但Firefox是即时的。谢谢

我的HTML:

我的Javascript:

$(document).ready(function(){
    $('div').mouseenter(function(){
        $(this).fadeTo(1000, 1);
    });
    $('div').mouseleave(function(){
        $(this).fadeTo(1000, .25);
});

脚本文件的顺序:由于您的脚本文件使用jQuery,因此它应该包含在jQuery库之后

作为调试客户端脚本问题的第一步,请查看浏览器控制台以查看是否存在任何错误

<html>
    <head>
        <title></title>
        <link rel='stylesheet' type='text/css' href='stylesheet.css'/>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.js"></script>
        <script type='text/javascript' src='script.js'></script>
    </head>
    <body>
        <div>Hover Over Me!</div>   
    </body>
</html>

演示:

您需要一个额外的
结束。使用开发者控制台来发现这样的小错误!使用记事本++。抱歉,我没有将其正确复制到stackoverflow。我有});谢谢不知道脚本的顺序。控制台日志显示:未捕获引用错误:$未定义,无法加载资源。@Nexus已更新,您包含了jQuery UI库而不是jQuery库Uncaught ReferenceError:$未定义:script.js:1未能加载资源:file://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.js@Nexus你查过电话了吗demo@Nexus尝试将jquery的src更新为
http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.js
,这可能是因为您正在从
文件:xxx
地址运行测试,因此需要为远程资源指定协议。。。
$(document).ready(function(){
    $('div').mouseenter(function(){
        $(this).fadeTo(1000, 1);
    });
    $('div').mouseleave(function(){
        $(this).fadeTo(1000, .25);
});
<html>
    <head>
        <title></title>
        <link rel='stylesheet' type='text/css' href='stylesheet.css'/>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.js"></script>
        <script type='text/javascript' src='script.js'></script>
    </head>
    <body>
        <div>Hover Over Me!</div>   
    </body>
</html>
$(document).ready(function () {
    $('div').mouseenter(function () {
        $(this).fadeTo(1000, 1);
    });
    $('div').mouseleave(function () {
        $(this).fadeTo(1000, .25);
    });
});