I have a task to update a group of buttons with different buttons depending on the initial button chosen.
Button1: when clicked, both buttons will be replaced by Button1a and Button1b
Button2: when clicked, both buttons will be replaced by Button2a and Button2b
This is what I have done so far:
<div class="buttons">
<div class="buttons1-2">
<button type="button" class="btn btn1">Button 1</button>
<button type="button" class="btn btn2">Button 2</button>
</div>
<div class="buttons1a-b">
<button type="button" class="btn btn1a">Button 1a</button>
<button type="button" class="btn btn1b">Button 1b</button>
</div>
<div class="button2a-b">
<button type="button" class="btn btn2a">Button 2a</button>
<button type="button" class="btn btn2b">Button 2b</button>
</div>
</div>
I have hidden the 1a-b and 2a-b buttons:
.button1a-b {
display: none;
}
.button2-b {
display: none;
}
However, I am having trouble writing the JavaScript code for this functionality. Can anyone assist me in coding this in JavaScript? Additionally, if there is a more efficient way to structure my HTML/CSS for this task, please share your recommendations.