Adds a fallback for browsers that do not support the placeholder attribute.
Probably the most simple solution for this out there.
I found many others where you need extra CSS. This is so simple that you just have to call the class and you have placeholder support for all browsers!
Published under the MIT-License.
Just add the PlaceholderSupport.js to your website and call:
#JS
window.addEvent('domready',function(){
new PlaceholderSupport();
});
Will add placeholder functionality to all inputs and textarea elements with a "placeholder" attribute.
#JS
window.addEvent('domready',function(){
new PlaceholderSupport('input.myInputWithPlaceholder');
});
Will add the placeholder only to inputs with the class "myInputWithPlaceholder". But this input needs also a placeholder attribute with a text!