Skip to content

Instantly share code, notes, and snippets.

@dziudek
Created May 26, 2013 21:45
Show Gist options
  • Save dziudek/5654111 to your computer and use it in GitHub Desktop.
Save dziudek/5654111 to your computer and use it in GitHub Desktop.
IE <= 9 placeholder polyfill in MooTools
window.addEvent('domready', function() {
document.getElements('*[placeholder]').each(function(el) {
if(el.get('value') === '') {
el.set('value', el.getProperty('placeholder'));
}
el.addEvents({
'focus': function() {
if(el.get('value') === el.getProperty('placeholder')) {
el.set('value', '');
}
},
'blur': function() {
if(el.get('value') === '') {
el.set('value', el.getProperty('placeholder'));
}
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment