Jack Raiden Jack Raiden - 1 month ago 5
HTML Question

HTML button causes all JS functions to be undefined

When I add the line for a button to enable a clock in HTML and add the respected function in a tag (which may or may not work by the way), then all functions on that page are now undefined. I only have one other function on that page, so it could just be that. I've looked for a while for syntax issues but I can't find anything.

JavaScript, then CSS, then HTML for the page.

function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML =
h + ":" + m + ":" + s;
var t = setTimeout(startTime, 500);
function checkTime(i) {
if (i < 10) {i = "0" + i};
return i;

.headtitle {
font-family: "Courier New", Courier, monospace;
display: flex;
flex-wrap: wrap;
justify-content: center;
border: 5px solid #00f;
padding: 10px;
display: flex;
flex-wrap: wrap;
justify-content: center;
font-size: 1.25rem
word-spacing: 30px;
background-image: url("http://i.kinja-img.com/gawker-media/image/upload/a942qcqwrcmveiq37zli.png");
color: white;
display: inline;
.list li{
display: inline;
padding-left: 1.5rem;
border: 1px solid #f00;
padding: 5px
position: relative;
top: 2px;
left: 2px;

<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="Website task.css">
<script type="text/javascript" src="new 1.js"></script>
<script type="text/javascript">
function openFunction() {
window.open('Website Task.html', '_blank');
function showTime() {
document.getElementByID("currentTime").innerhtml = "The time is now" startTime();
<title>Javascript page</title>
<div class="header">
<h1 class="headtitle">Javascript demo page</h1>
<p class="subtitle">This page is for demonstrating functions in Javascript in particular, as well as jQuery.</p>
<p id="currentTime"></p>
<button onclick="showTime()">Click here to show the time</button>
<a class="clickText" onclick="openFunction()">Click this text to return to the previous page in a new window</a>
<button class="JavascriptButton" onclick="window.location='Website Task.html';">Previous page</button>


you have syntax errors in your code. Simply open dev tools to find this out...

document.getElementById("currentTime").innerhtml = "The time is now" startTime();

=> "the time is now " + startTime();

but your startTime function doesn't return anything so it's useless like that