Не получается заставить это работать: вот код:
// Clears the default text on click, but restores if nothing is entered
var clearText = (function(){
$("input:text").each(function () {
var default_value = this.value;
$(this).focus(function(){
if(this.value == default_value) {
this.value = '';
}
});
$(this).blur(function(){
if(this.value == '') {
this.value = default_value;
}
});
});
$("textarea").each(function () {
var default_value = this.value;
$(this).focus(function(){
if(this.value == default_value) {
this.value = '';
}
});
$(this).blur(function(){
if(this.value == '') {
this.value = default_value;
}
});
});
})();
$('html').on('keydown', 'body', function(e){
if (e.which == 9)
{
clearText();
}
});
clearText () определенно вызывается при загрузке страницы, но тогда он не работает как функция обратного вызова?Я не совсем уверен, почему, кто-нибудь может мне помочь?
Приветствия