Created
March 8, 2012 10:20
-
-
Save jnaskali/2000163 to your computer and use it in GitHub Desktop.
JavaScript: Input onFocus onBlur change
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
| <script type="text/javascript"> | |
| function myFocus(element) { | |
| if (element.value == element.defaultValue) { | |
| element.value = ''; | |
| } | |
| } | |
| function myBlur(element) { | |
| if (element.value == '') { | |
| element.value = element.defaultValue; | |
| } | |
| } | |
| </script> | |
| <input type="text" id="first" value="Insert text here..." onfocus="myFocus(this);" onblur="myBlur(this);"> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment