Requires jQuery version Add the class clear-input to any text input element whose value you want cleared when it gains focus. The initial value will be replaced when the input loses focus, and no new text has been entered.
If you prefer to not add classes to your elements, you can alternatively call clearInput() on any jQuery input object.
You can have multiple clear-input fields on a single page, and they will not conflict.
<input name="email" class="clear-input" value="Email address">
<input name="email" value="Enter email" id="clear-me">
<script type="text/javascript">
$(document).ready(function(){
$("#clear-me").clearInput();
});
</script>
You can download this project in either zip or tar formats.
You can also clone the project with Git by running:
$ git clone git://github.com/afeld/jquery-clearinput
Compatible with jQuery v1.2+.
Aidan Feldman (aidan.feldman@gmail.com)