【发布时间】:2018-12-16 15:52:32
【问题描述】:
无论我尝试什么,我似乎都无法将我的 JQuery 文件链接到我的 HTML 文件。当我将 JQuery 代码放在 HTML 页面上的脚本部分中时,JQuery 代码本身可以工作,但不能从文件中工作。
这是我的 HTML 的开头:
<!DOCTYPE html>
<!--Index page-->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- CSS file link -->
<link href="login-css.css" rel="stylesheet" type="text/css">
<!-- JQuery link -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="js/jquery.js" type="text/javascript"></script>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
和身体的底部:
<!-- Bootstrap jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
这里是 JQuery 代码:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(window).on('load', function () {
alert("For this prototype please use admin as username and password as password");
});
</script>
【问题讨论】:
-
.js文件必须有 JavaScript 代码,而不是 HTML 标记。 -
您在开发工具控制台中看到了什么?
-
你为什么要导入 jQuery 两次(一次在顶部,一次在末尾)?
标签: javascript jquery html