Изменить значение текстового поля при нажатии
09.08.2015
<input type="text" class="default-value" size="30" value="Enter keywords here" /> <input type="text" class="default-value" size="30" value="Another search box" />
$('.default-value').each(function() {
var default_value = this.value;
$(this).css('color', '#666');
$(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;
}
});
});
