This is not another jQuery plugin ;)
Simple library that provides placeholder
behavior to IE 7+.
It should also works fine with older FF or Opera (not tested).
- Read section When you should not use it? of this document.
- Download library and put it in your code.
- Execute
window.initPlaceholder()
method after window load.
Important
Its also possible to use ``initPlaceholder``` only at selected element. For example when you are using ajax you can initialize placeholders after sending request only at ajax container element.
window.initPlaceholder(document.getElementById('ajax-container'));
You probably also want to make elements with placeholders italic style with gray color.
This can be done because every single element with active placeholder gets .placeholder
class.
Those lines in css should do the job
.placeholder {
font-style: italic;
color: #a2a2a2;
}
-
First of all this is only a hack. Until developers will not stop using such scripts old browsers will still be alive. So if there is any posibility to not use it (for example by using
label
elements in html) do it! -
If you are using jQuery, mootls, yui or any other library you should't use this script because there are many placeholder simulators based on different libraries.
If you can see any typos, errors or potential improvements you are welcome to fork this project and create pull request :)