Last active
June 18, 2016 14:10
-
-
Save andykillen/b1931a4ea67752039a5f2cde8eb9508a to your computer and use it in GitHub Desktop.
Its gives better performance to use a javascript object than it does to use a jQuery selector.
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
var el = document.getElementById('header'); // this is for #header not <header> | |
$(el).('.some-class-used-in-header').each(function(index){ | |
// do something!! to each of the things with this class | |
}); | |
$(el.getElementsByTagName('nav')).on('touchstart click', 'a', function(e){ | |
// do something when an <A> inside a <NAV> inside #header is clicked. | |
e.preventDefault(); // prevents the default click action | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment