/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$('.default-value').each(function() { var default_value = this.value; $(this).css('color', '#666'); // this could be in the style sheet instead $(this).focus(function() { if(this.value == default_value) { this.value = ''; $(this).css('color', '#333'); } }); $(this).blur(function() { if(this.value == '') { $(this).css('color', '#666'); this.value = default_value; } }); });