html代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="2.js"></script>
</head>
<body>
<div id="div"></div>
<script src="1.js"></script>
</body>
</html>
1.js代码
document.getElementById('div').innerText=1
2.js代码
document.getElementById('div').innerText=2

运行效果
结论
如果一个js文件涉及某个html元素操作,该js文件应该放到</body>前面