Last active
August 29, 2015 14:19
-
-
Save sanusart/b42cfe6f8ed948ee48b8 to your computer and use it in GitHub Desktop.
input[type="text"] toggle default value or empty #jquery #form #input
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
| // Toggle default value on `input[type="text"]` and `textarea` | |
| var el = $('input[type=text], textarea'); | |
| el.focus(function(e) { | |
| if (e.target.value == 'name') | |
| e.target.value = ''; | |
| }); | |
| el.blur(function(e) { | |
| if (e.target.value == '') | |
| e.target.value = 'name'; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment