Skip to content

Instantly share code, notes, and snippets.

@jtulk
Last active August 29, 2015 14:27
Show Gist options
  • Save jtulk/d1893d6ff0fdd9247730 to your computer and use it in GitHub Desktop.
Save jtulk/d1893d6ff0fdd9247730 to your computer and use it in GitHub Desktop.
Example #4: Rewriting jQuery's .each() in Vanilla JS
// Loop through the elements in the array-like object
// and attach an event listener to each element
inputs.forEach(function(el, index, array){
el.addEventListener('focus', textInputFocusHandler);
el.addEventListener('blur', textInputBlurHandler);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment