I want to change the background color of a page 5 seconds after the initial load. This is my code so far but it's not working:
var startDate = new Date();
var startTime = startDate.getTime();
var nowDate = new Date();
var nowTime = nowDate.getTime();
var timeDifference = nowTime - startTime;
function difference() {
if (timeDifference = 5000) {
$("#body").css("background-color", "red");
}
}
I would also like to write out the time difference, but it only works with document.write()
.