I want to create a dynamic title for my website using HTML and JavaScript. However, I'm getting an error in the developer console that says 'TypeError: null is not an object (evaluating 'document.getElementById("send").addEventListener')'. I want to understand why it's not reading the objects in the JavaScript-defined array.
JS:
var titles = ["My website", "Glad to see you!", "Have a nice day!"];
var index = 0;
function changeTitle() {
document.getElementById("title").innerText = titles[index];
index = (index + 1) % titles.length;
}
setInterval(changeTitle, 7000);
HTML :
<title id="title">My website</title>