1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
736 B
JavaScript

var list = document.querySelectorAll("#principles-list > div");
var dropdown = document.getElementById("principles-dropdown");
var content = document.querySelectorAll("#principles-content > div");
var i;
function change_content(id) {
for (i = 0; i < content.length; i++) {
if (content[i].id == id)
content[i].classList.add("visible");
else
content[i].classList.remove("visible");
}
}
for (i = 0; i < list.length; i++) {
list[i].addEventListener("click", function() {
for (i = 0; i < list.length; i++) {
list[i].classList.remove("active");
}
this.classList.add("active");
change_content(this.getAttribute("data-value"));
});
}
dropdown.addEventListener("change", function() {
change_content(this.value);
});