I am beginning to program. In the bottom code, when run, will completely refresh the page. How can I avoid this? Thank you very much for your time!
<h1>Space Calculator Demo</h1><br> If you were to start a trip at
<script type="text/javascript">
function printTime() {
var d = new Date();
var hours = d.getHours();
var mins = d.getMinutes();
var secs = d.getSeconds();
document.body.innerHTML = hours + ":" + mins + ":" + secs;
}
setInterval(printTime, 1000);
</script>
<div id="time"></div> , how long would it take you and how much food and water would you need?
document.body.innerHTMLto the text.document.body.innerHTMLjust has to be:document.getElementById('time').innerHTML, example