Created
December 30, 2016 17:05
-
-
Save adamschwartz/a27c414bbea90dad81cea7c47cbce8b7 to your computer and use it in GitHub Desktop.
Automatically set CSS --value variable on inputs
This file contains hidden or 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
| inputSelector = 'textarea, input[type="text"], input[type="email"]'; | |
| for (input of document.querySelectorAll(inputSelector)) { | |
| input.style.setProperty('--value', input.value); | |
| } | |
| document.addEventListener('input', e => { | |
| var input = e.target; | |
| input.style.setProperty('--value', input.value); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment