小编Res*_*hun的帖子

jQuery只能在HTML文件中使用,而不能在JS文件中使用

我刚刚设置了jQuery(有点像jQuery脚本),但是当我想在我的.js文件中使用它时,它没有用.后来我尝试使用标签在我的HTML文件中使用jQuery,但之后就可以了!我想在我的.js文件中编写脚本,所以有人可以帮我这个吗?谢谢!

HTML文件:

<!DOCTYPE html>
<html>

<head>
    <title>Test</title>

    <script src="test.js" ></script>
    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>

</head>

<body>
    <script>
        alert("My current jQuery version is "+jQuery.fn.jquery);
    </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

Javascript文件:

alert("I am running this from 'test.js'. My current version of jQuery is "+jQuery.fn.jquery);
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

-4
推荐指数
1
解决办法
245
查看次数

标签 统计

html ×1

javascript ×1

jquery ×1