const toggleButton = document.getElementById('btn');
setInterval(displayTime,1000);
toggleButton.onclick= function toggle()
{
if (toggleButton.innerHTML=="Light") {
document.body.style.backgroundColor ="white";
document.getElementById('hours').style.color = 'black';
document.getElementById('minutes').style.color = 'black';
document.getElementById('seconds').style.color = 'black';
document.getElementById('session').style.color = 'black';
toggleButton.innerHTML ="Dark";
toggleButton.style.color ="white";
toggleButton.style.backgroundColor ="black";
} else {
document.body.style.backgroundColor ="black";
document.getElementById('hours').style.color = 'white';
document.getElementById('minutes').style.color = 'white';
document.getElementById('seconds').style.color = 'white';
document.getElementById('session').style.color = 'white';
toggleButton.innerHTML ="Light";
toggleButton.style.color ="black";
toggleButton.style.backgroundColor ="white";
}
};
function displayTime(){};
How can I get this code to function properly? I attempted using addEventListener('click', toggle) instead of onclick, but it did not work. I want the timer to continue running, with the toggle function only activating when the specified button with the id "btn" is clicked.