I have come back to coding having been awayfor a number of years and am re-learning, so I’m completely new.
I’m wanting to write a simple script that generates the time when a button is pressed:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Time Button!</title>
</head>
<body>
<h1>Time Button!</h1>
<p>Press the Button to get the time.</p>
<script type="text/javascript">
var currentTime = new Date();
<button type="button"
onclick="document.write(currentTime);"
</button>
</script>
</body>
</html>
I expect to see an Instruction and a button displayed. On [PRESS] the time will be displayed.
The Console states, “Uncaught syntax error” and points to: <button type=”button”
Frankly I do not see where the error lies.
New contributor
Hamish Johnston is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.