You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
577 B

  1. window.onload = function() {
  2. (function() {
  3. var hamburger = {
  4. navToggle: document.querySelector('.nav-toggle'),
  5. nav: document.querySelector('.links'),
  6. doToggle: function(e) {
  7. e.preventDefault();
  8. this.navToggle.classList.toggle('expanded');
  9. this.nav.classList.toggle('expanded');
  10. }
  11. };
  12. document.addEventListener('click', function(e) {
  13. if (e.target.className.includes("nav-toggle")) {
  14. hamburger.doToggle(e);
  15. } else {
  16. hamburger.navToggle.classList.remove('expanded');
  17. hamburger.nav.classList.remove('expanded');
  18. }
  19. });
  20. }());
  21. }