I am working on a little website, which loads the first page but keeps the others hidden until the user clicks the relevant button.
So, when the user clicks "Start Page 2" then the html has an onclick method:
onclick="startPageTwo()"
below is the javascript:
const startPageOne = () => {
document.getElementById("section-one").style.display = "flex";
document.getElementById("section-two").style.display = "none";
document.getElementById("section-three").style.display = "none";
}
const startPageTwo = () => {
document.getElementById("section-two").style.display = "flex";
document.getElementById("section-one").style.display = "none";
document.getElementById("section-three").style.display = "none";
}
const startPageThree = () => {
document.getElementById("section-three").style.display = "flex";
document.getElementById("section-one").style.display = "none";
document.getElementById("section-two").style.display = "none";}
as you can see, there are 3 functions, each doing something slightly different.
How would I go about making a function that checks the id or class of the button pressed, and opens & closes the appropriate page?