I have a quick question. I'm not sure exactly what this is called, but how do you write a div into a div? Example, I want to create a simple game that stays on the same page. When a button is clicked to move on to the next part of the game, the original div will be erased and a new one put on top of that.
So, lets say I have a div called "start" and another called "option 1". Option 1 would be hidden, while start is displayed as the home page. When you click a button on the "start" div, it writes the "option 1" div over that, erasing the first div.
My HTML code:
<div id="start">
<button class="button" onclick="swordsman()">Choose Swordsman</button>
</div>
My JS:
function swordsman()
{
document.getElementById("start")writeDiv.id="option 1"
}
And that is where I am stuck, I don't know the code to replace a div with another div. It's purely a guess.
I am new to JavaScript, so excuse my stupidity.
innerHTML- developer.mozilla.org/en-US/docs/Web/API/Element.innerHTML