Created
September 11, 2018 13:57
-
-
Save snowleo208/846f5ce737390c6f689214d3febce717 to your computer and use it in GitHub Desktop.
This file contains 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.addEventListener("load", function() { | |
// use slice for supporting IE 11 | |
Array.prototype.slice.call(document.querySelectorAll('.menu-item')).forEach(item => { | |
const target = item.getAttribute('data-id'); | |
item.addEventListener('click', e => { | |
e.preventDefault(); | |
scroll(document.getElementById(target)); | |
}); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment