Skip to content

Instantly share code, notes, and snippets.

@jtulk
Created August 10, 2015 17:48
Show Gist options
  • Save jtulk/4d4dbd6b429c6afa6c1f to your computer and use it in GitHub Desktop.
Save jtulk/4d4dbd6b429c6afa6c1f to your computer and use it in GitHub Desktop.
Example #5: Rewriting jQuery's .each() in Vanilla JS
// Use the Array.prototype.forEach method and the
// .call method to loop through the array-like object
Array.prototype.forEach.call(inputs, 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