How to set a timer?
Hi! I have two questions: 1) Why do I need to write "[0]:" to make my code working? 2) Why is "setTimeout function" doesn't work? Here's the code <html> <body> <div class="container">Hi there! My name is container</div> <style> body { background-color: #333 } .container { background-color: #000; color: #fff; padding: 10px; text-align: center;} </style> <script> window.onload = function colorChanger() { var changeColor = document.getElementsByClassName("container"); changeColor[0].style.color = "#000"; changeColor[0].style.backgroundColor = "#fff"; }; setTimeout(colorChanger, 5000); </script> </body> </html> Thanks for advance