I’d like to create a script that updates a number on my website monthly. I’ve made it work with miliseconds. But how do I do it with a month. It’s something with the setInterval, righ?
let m2 = document.createElement("h2");
function naturfonden() {
m2.innerHTML = "240";
let parent = document.querySelector("#menu-item-2472");
// I'm placing the number in the menu
parent.appendChild(m2);
setInterval(displayM2, 5000);
function displayM2() {
let numberOfM2 = parseInt(m2.innerText);
numberOfM2 += 10;
console.log(typeof(numberOfM2));
console.log(numberOfM2);
m2.innerHTML = numberOfM2;
}
}
naturfonden();
I tried following a tutorial and succeeded but I couldn’t find one that fitted my need.