只是想知道是否有人可以帮助我。我遇到了一个从未遇到过的奇怪问题,但我不知道如何解决它:
<head>
<title>Welcome to Edge Hill Computing</title>
<link rel="stylesheet" href="style.css"/>
<link rel="stylesheet" href="index.css"/>
<script type="text/javascript" src="global.js"></script>
<script type = "text/javascript" src="jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
</head>
我的 javascript 文件和 jquery 文件已导入此处。其中“应该”到外部 jquery 文件。但事实并非如此,我必须使用脚本标签从那里运行代码。有什么可能的解决方案吗?
如果有帮助,Global.js 中的代码是这样的:
$(document).ready(function(){
$("#txtbox").keyup(function(){
var name = $('#txtbox').val();
$('#display').html((name));
});
});
最佳答案
global.js 应该在 jQuery 之后加载
关于javascript - 我的代码在 <script> 标记中工作,但在外部文件中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29266614/