Clear all text fields on focus based on original value with single function

[javascript]
var $originalValue = ”;

$(‘.text’).focus(function () {
$(this).addClass(‘active’);
if ($(this).val() == $(this).attr(‘title’)) {
$originalValue = $(this).val();
$(this).val(”);
}
});

$(‘.text’).blur(function () {
$(this).removeClass(‘active’);
if ($(this).val() == ”) {
$(this).val($originalValue);
}
});
[/javascript]

Leave a Reply