[英]Can't get my javascript to load
I just got into javascript today but I can't figure out how to load it into my website. 我今天刚开始使用javascript,但无法弄清楚如何将其加载到我的网站中。 I've been looking everywhere for a solution but nothing seems to help.
我一直在到处寻找解决方案,但似乎无济于事。
This is my body in index.html 这是我在index.html中的身体
<body>
<p id="testid">TEST</p>
<script type="text/javascript" src="./script.js"></script>
</body>
This is some example java script code I grabbed off the internet, I tried other examples as well but I can't get anything to work. 这是我从互联网上获取的一些Java脚本示例代码,我也尝试了其他示例,但是我什么都无法工作。
<script type="text/javascript">
var para = document.createElement("p");
var node = document.createTextNode("This is new.");
para.appendChild(node);
var element = document.getElementById("testid");
element.appendChild(para);
</script>
The html and javascript file are both in the same folder, I'm clueless as to why this won't work... I appreciate any help :) html和javascript文件都在同一个文件夹中,我不知道为什么这行不通...感谢您的帮助:)
省略.js文件中的<script></script>
标记。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.