Created
August 10, 2015 17:42
-
-
Save jtulk/2369b6cfd34e795e6ccb to your computer and use it in GitHub Desktop.
Examples for a blog post on 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 = $('.text-input'); | |
// Create event handling functions | |
function textInputFocusHandler(){ console.log('focus');} | |
function textInputBlurHandler(){ console.log('blur'); } | |
// Attach focus & blur handlers to selected inputs | |
$inputs.on('focus', textInputFocusHandler); | |
$inputs.on('blur', textInputBlurHandler); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment