SJ19
SJ19

Reputation: 2123

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. 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 :)

enter image description here

Upvotes: 0

Views: 84

Answers (1)

Travesty3
Travesty3

Reputation: 14469

Omit the <script></script> tags in the .js file.

Upvotes: 12

Related Questions