Changing html with javascript
I have the following html code: <!DOCTYPE html> <html> <head> <title>Test Website</title> <script src = "testsite.js"></script> </head> <body> <div>Current time:</div> <div id = "currentTime">00:00:00</div> </body> </html> and the following javascript code: var item = document.getElementById("currentTime"); var date = new Date(); var hours = date.getHours(); var minutes = date.getMinutes(); var seconds = date.getSeconds(); item.innerHTML = hours + ":" + minutes + ":" + seconds; but for some reason it's not working. I've already tested that the script is correctly added to the website (by replacing it with alert("test")), and the problem seems to be either the selecting or the changing of the element.