Created
December 7, 2011 16:51
-
-
Save dfadler/1443556 to your computer and use it in GitHub Desktop.
Saves default text input value, removes on click, and resets if the user does not enter a string
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
$('input[type=text]').each(function(i){ | |
var defaultValue = new Array(); | |
defaultValue[i] = $(this).val(); | |
$(this).click(function(){ | |
if($(this).val() == defaultValue[i]){ | |
$(this).val(''); | |
} | |
}); | |
$(this).focusout(function(){ | |
if($(this).val() == ''){ | |
$(this).val(defaultValue[i]); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment