Last active
August 22, 2018 12:18
-
-
Save tuor4eg/5b3f6dd778637348c24ac074eff3165f to your computer and use it in GitHub Desktop.
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
| export default () => { | |
| // BEGIN (write your solution here) | |
| const makeActive = (element) => { | |
| const link = element.getAttribute('href').substr(1); | |
| const currentTab = element.parentNode.parentNode.getElementsByClassName('nav-link active')[0]; | |
| const currentLink = currentTab.getAttribute('href').substr(1); | |
| const currentDiv = document.getElementById(link); | |
| const findDiv = document.getElementById(link); | |
| currentDiv.setAttribute('class', 'tab-pane'); | |
| findDiv.setAttribute('class', 'tab-pane active'); | |
| element.setAttribute('class', 'nav-link active'); | |
| currentTab.setAttribute('class', 'nav-link'); | |
| return; | |
| }; | |
| const nav = document.querySelectorAll('a[data-toggle]'); | |
| nav.forEach(node => { | |
| node.addEventListener('click', makeActive(node)); | |
| }); | |
| // END | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment