Kod:
var niceSearch = {
s : Object,
init : function() {
altValue = 'Vill du inte S\u00F6ka?';
for (var i = 0; i < arguments.length; i++) {
this.s[i]=$(arguments[i]);
addEvent(this.s[i],'focus',this.focus,false);
addEvent(this.s[i],'blur',this.blur,false);
}
},
focus : function() {
if ( this.value == this.defaultValue || this.value == altValue) {
this.value = '';
this.className = 'focus';
}
},
blur : function() {
if ( this.value == '' ) {
this.value = altValue;
this.className = 'blur';
}
}
};
Jag använder något sänt här, men så är jag ju lite omständig av mig också
.
Bör notera att ovanstående kräver någon form av EventHandler.