Created
January 19, 2016 18:37
-
-
Save fredericAerts/66d51b7db8283f82dd75 to your computer and use it in GitHub Desktop.
web developer in 3days - v7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.document.addEventListener('DOMContentLoaded', function() { | |
var tabLinks = window.document.querySelectorAll('.tab-links-item'); | |
var tabLinksArray = [].slice.call(tabLinks); | |
tabLinksArray.forEach(function(tabLink) { | |
tabLink.addEventListener('click', function(event) { | |
event.preventDefault(); | |
if(!tabLink.classList.contains('active')) { | |
// update tab links | |
tabLink.parentNode.querySelector('.tab-links-item.active').classList.remove('active'); | |
tabLink.classList.add('active'); | |
// update tab panes | |
var targetPane = window.document.querySelector(tabLink.getAttribute('href')); | |
targetPane.parentNode.querySelector('.active').classList.remove('active'); | |
targetPane.classList.add('active'); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment