I have a small html page, where if the user clicks on one of the buttons, it will change the day. I have a function where it says what day it is today, but I want the user to be able to press ">", which will change the day from today to the next day. And the previous day if you press "<". I am no fully sure on how I should proceed now.
var date = new Date();
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
document.getElementById("todayField").innerHTML = days[date.getDay()];
function next() {
var date = new Date();
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
document.getElementById("todayField").innerHTML = days[date.getDay()];
if (btnNext.click) {
days++;
document.getElementById("todayField").innerHTML = days[date.getDay()];
}
}
function prev() {
var date = new Date();
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
document.getElementById("todayField").innerHTML = days[date.getDay()];
if (btnNext.click) {
days--;
document.getElementById("todayField").innerHTML = days[date.getDay()];
}
}
<p>Click to change day</p>
<button type="button" name="btnPrev" onclick="next()"><</button>
<button type="button" name="btnNext" onclick="prev()">></button>
<p id="todayField"></p>
All help is appreciated!