There are two divs with different content inside, and I want to toggle between them using a button.
Here are my two divs with classes "step1Content" and "step2Content" respectively.
<div class='step1Content'> Content1 </div>
<div class='step2Content'> AnotherContent </div>
I have set the style display: block for step1Content.
.step1Content { display: block; }
I have set the style display: none for step2Content.
.step2Content { display: none; }
There is a button that should toggle between these two to show or hide.
<button onclick='step2()'>2. Taskeros and Prices</button>
Here is the JavaScript function:
function step2(){
document.getElementsByClassName('step1Content')[0].style.display = 'none';
document.getElementsByClassName('step2Content')[0].style.display = 'block';
}
However, when I click the button, nothing happens. Any idea why this might be occurring?