Last active
May 3, 2017 14:18
-
-
Save Flobin/f95c4227ab79dd87333b to your computer and use it in GitHub Desktop.
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
[].slice.call( document.querySelectorAll( '.input' ) ).forEach( function( inputEl ) { | |
// in case the input is already filled.. | |
if( inputEl.value.trim() !== '' ) { | |
classie.add( inputEl.parentNode, 'input--filled' ); | |
} | |
// events: | |
inputEl.addEventListener( 'focus', onInputFocus ); | |
inputEl.addEventListener( 'blur', onInputBlur ); | |
} ); | |
function onInputFocus( ev ) { | |
classie.add( ev.target.parentNode, 'input--filled' ); | |
} | |
function onInputBlur( ev ) { | |
if( ev.target.value.trim() === '' ) { | |
classie.remove( ev.target.parentNode, 'input--filled' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment