No Description

index.js 883B

123456789101112131415161718192021222324252627282930313233343536373839
  1. ///// !!! index.php !!! /////
  2. // Get tab links and tab panes
  3. let tabLinks = document.querySelectorAll('#main-sidebar a');
  4. let tabPanes = document.querySelectorAll('.main-content-box');
  5. // Add event listener to all tab links
  6. tabLinks.forEach(tabLink => {
  7. tabLink.addEventListener('click', tabChange);
  8. });
  9. // Add selected link style and remove those who were not selected
  10. function tabChange(e) {
  11. e.preventDefault();
  12. // Change the style of the links
  13. tabLinks.forEach(tabLink => {
  14. if(tabLink === e.target) {
  15. tabLink.classList.add('active');
  16. } else {
  17. tabLink.classList.remove('active');
  18. }
  19. });
  20. // Change the opacity of each of the panes
  21. tabPanes.forEach(tabPane => {
  22. if(tabPane.id === e.target.hash.substring(1)) {
  23. tabPane.classList.add('show');
  24. } else {
  25. tabPane.classList.remove('show');
  26. }
  27. });
  28. }