Created
December 30, 2011 20:15
-
-
Save SpencerCooley/1541299 to your computer and use it in GitHub Desktop.
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
$(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