Skip to content

Instantly share code, notes, and snippets.

@SpencerCooley
Created December 30, 2011 20:15
Show Gist options
  • Save SpencerCooley/1541299 to your computer and use it in GitHub Desktop.
Save SpencerCooley/1541299 to your computer and use it in GitHub Desktop.
$(function(){
//this makes the default value of an input disappear when you focus on the input text field.
//default values reappear when input is unfocused under the condition that value="".
var smart_input = function( input_id, default_value){
$(input_id).focus(function(){
if($(input_id).val() === default_value){
$(this).val('');
$(input_id).focusout(function(){
if($(this).val() === ''){
$(this).val(default_value);
}//ends if statement
});//ends focusout
};//ends if statement
});//ends focus
};//ends the smart_input function
smart_input('#working_name', 'First Name');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment