I just started learning JS and I keep failing to make a function successfully run via external javascript. I have no idea what is wrong. The thing is that it works when using inline javascript, but not external one. Here's the following code:
{% load static %}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="{% static 'css/main.css' %}">
<title id='title'> Home </title>
</head>
<body>
<input type="button" id="btn" value="testas" onclick="myFunction()" />
<address>
Written by <a href="mailto:[email protected]">Jon Doe</a>
</address>
<script src="{% static 'javascript/js.js' %}"></script>
</body>
</html>
JS:
function ChangeTitle() {
document.getElementById("title").innerHTML = 'Homepage';
}
I want to change the title of "Home" to "Homepage" but it doesn't work on external JS.