Created
August 10, 2015 17:45
-
-
Save jtulk/7caa079ff366007489a3 to your computer and use it in GitHub Desktop.
Example #2: Rewriting jQuery's .each() in Vanilla JS
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
// Select all HTML elements with class .text-input | |
var inputs = document.getElementsByClassName('text-input'); | |
// Create event handling functions | |
function textInputFocusHandler(){ console.log('focus');} | |
function textInputBlurHandler(){ console.log('blur'); } | |
// Attach focus & blur handlers to selected inputs | |
inputs.addEventListener('focus', textInputFocusHandler); | |
inputs.addEventListener('blur', textInputBlurHandler); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment