Skip to content

Instantly share code, notes, and snippets.

@ng-the-engineer
Created April 27, 2021 10:38
Show Gist options
  • Save ng-the-engineer/2efb56b6586763652ffd818496709f8a to your computer and use it in GitHub Desktop.
Save ng-the-engineer/2efb56b6586763652ffd818496709f8a to your computer and use it in GitHub Desktop.
Code snippet of CV2
function switchTab(tab, selected, color) {
var contents = document.getElementsByClassName("tabContent");
for (var i = 0; i < contents.length; i++) {
close(contents[i]);
}
var buttons = document.getElementsByClassName("tabButton");
for (var i = 0; i < buttons.length; i++) {
changeColor(buttons[i], "");
}
show(document.getElementById(tab));
changeColor(selected, color);
}
function changeColor(el, color) {
el.style.backgroundColor = color;
}
function close(el) {
el.style.display = "none";
}
function show(el) {
el.style.display = "block";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment