0

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.

1 Answer 1

1

in your JS script you only created function, now you need to call it.

Just add ChangeTitle(); at the end of script.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.