Last updated February 1, 2009. Created by joachim on February 1, 2009.
Log in to edit this page.
It's often useful to have default text in a field. For example search boxes that say "Enter some search terms", or example text. But selecting this text to overwrite it is a pain for the user.
Here is a snippet of jquery to blank a field on first click (and then not blank it any more, obviously).
/**
* Clears field texts on click.
*/
$(document).ready(function() {
$('YOUR SELECTOR HERE').click(function () {
$(this).attr('value', '');
$(this).unbind('click');
});
});