I want to set up a page where the visibility of certain elements on a page are toggled by buttons, but for some reason, my code is simply ignored / does absolutely nothing.
I can get this to work when using ID's, but then only the first instance of the ID on the page gets changed while the rest are ignored. With classes, nothing happens.
I'm sure I'm missing something basic here, but I can't figure out what. Please check below:
function georgianInfo() {
document.getElementByClassName("georgian").style.display = "block";
document.getElementByClassName("international").style.display = "none";
}
function internationalInfo() {
document.getElementByClassName("georgian").style.display = "none";
document.getElementByClassName("international").style.display = "block";
}
.georgian {
display: none;
}
.international {
display: block;
}
<form><input type="button" onClick="georgianInfo()" value="georgian students"></form>
<form><input type="button" onClick="internationalInfo()" value="international students"></form>
<h4 class="margin-rmv">Admissions Information</h4>
<h5 class="georgian">Georgian Students Admissions Information</h5>
<h5 class="international">International Students Admissions Information</h5>
Refer codepen: https://codepen.io/escapetomars/pen/vxBLgg