链接到外部js时jquery没有运行

use*_*039 0 html javascript jquery

每当我将脚本放在与script.js相同的文件夹中的另一个文件中时,它就不会运行.它只在我将代码包含在脚本标记中时运行.

我用这个简单的jquery代码试了一下.每当第三个脚本标记被取消注释时,它都可以工作,但我现在所拥有的设置不会运行.

HTML

<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script type="text/javascript" scr="script.js"></script> // <!-- doesn't run -->
    <!--script> // <!-- only runs inside the html file -->
        $(document).ready(function(){
            $('p').click(function(){
                $(this).hide();
            });
        });
    </script-->
</head>
<body>
    <p>Click to hide.</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

的script.js

$(document).ready(function(){
    $('p').click(function(){
        $(this).hide();
    });
});
Run Code Online (Sandbox Code Playgroud)

有谁知道我做错了什么?

Que*_*tin 5

scr不是src.使用验证器确保您没有拼写错误的属性名称.