I need to make 2 div content visible by pressing a button. I do not use "getElementsById" since the Id should be unique. The divs will be in different location so I cannot wrap then with another div. I am aiming of using plain JS.
Background for doing this is to have a button for demos where one iframe will show an app, and the other iframe will show the app description. The button click should therefor activate 2 divs (that are spreadout in the code).
function display_both_divs() {
document.getElementsByClassName('boxes').style.display = "block";
}
body {
background-color: pink;
}
.boxes {
display: none;
}
.button {
width: 200px;
height: 60px;
}
<button
class="button"
type="button"
name="button"
onclick="display_both_divs()"
> Show boxes content
</button>
<div class="boxes">box_1</div>
<div class="boxes">box_2</div>