I just got into javascript today but I can't figure out how to load it into my website. I've been looking everywhere for a solution but nothing seems to help.
This is my body in 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.
<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 :)
省略.js文件中的<script></script>
标记。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.