I am trying to add text to my site based on the time. However, I cannot get it to work!
HTML:
<!doctype>
<html>
<head>
<link rel="stylesheet" type="text/css" href="index.css">
<script link="index.js"></script>
</head>
<body>
<div id="header">
<img id="bannerImage" src="banner.jpg" align="middle"></img>
</div id="header">
<section id="master">
<div id="navigation">
<ul>
<li class="navObject">About Me</li>
<li class="navObject">Products</li>
<li class="navObject">Contact</li>
<li class="navObject">FAQ</li>
</ul>
</div>
<div>
<h3 id="welcomeText"></h3>
</div>
</section>
</body>
</html>
JS:
var timeAdd = function(){
var today = new Date();
var todayHour = today.getHours();
var message;
switch(todayHour){
case(todayHour > 18):
message = "Good Evening!";
break;
case(todayHour > 12):
message = "Good Afternoon!";
break;
case(todayHour > 0):
message = "Good Morning!";
break;
default:
message = "Welcome!";
break;
}
return message;
};
var tag = document.getElementById("welcomeText");
tag.textContent(timeAdd());
I just want to be able to add the message to said div. When I try the page, nothing comes up. I have tried different ways, so, what am I missing?
tag.innerHTML = timeAdd()should work.switch(true)textContentproperty is not a function.