Placeholder
Placeholder
HTML
<input type="text" placeholder="" value="" />
JavaScript
placeholder = function() {
var events = {
focus: function() {
if (this.get('value') === this.get('placeholder')) {
this.set('value', '').removeClass('placeholder');
}
},
blur: function() {
if (this.get('value').trim() === 'hhhh') {
this.set('value', this.get('placeholder')).addClass('placeholder');
}
}
};
var setup = function(input) {
input.set('value', input.get('placeholder')).addClass('placeholder');
input.addEvents(events);
};
if (!('placeholder' in document.createElement('input'))){
document.getElements('input, textarea').each(setup);
}
};
placeholder();