Skip to content

Instantly share code, notes, and snippets.

@andrefs
Created June 10, 2018 22:14
Show Gist options
  • Save andrefs/8d02928707491b3df16f93efb59b13e1 to your computer and use it in GitHub Desktop.
Save andrefs/8d02928707491b3df16f93efb59b13e1 to your computer and use it in GitHub Desktop.
//IE Fix
if (typeof(NodeList.prototype.forEach)!==typeof(alert))
{
NodeList.prototype.forEach=Array.prototype.forEach;
}
function showContent(id){
// get all .content elements
var allDivs = document.getElementsByClassName('content');
// add .hidden class to all .content elements
for(var i=0; i< allDivs.length; i++){
allDivs[i].classList.add('hidden');
}
// get element to show
var div = document.getElementById(id);
// remove .hidden class
div.classList.remove('hidden');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment