Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (15 sloc) 1001 Bytes

Place Holder jQuery Plugin

This plugin will enable html5 placeholder attribute work in all browsers.

To use just include the plugin file along with jQuery. Then in your dom.ready function select the input elements you want to use then call placeholder() on them.

(function($) {
    $(document).ready(function() {
        $("input[placeholder]").placeholder();
    });
})(jQuery);

Your input elements need to have the placeholder attribute on them.

<input type="text" name="first-name" id="first-name" placeholder="John" />

Feature Plans

Some sort of feature detection in order to let browsers who support placeholder work natively.

About

Originally inspired by @robertbanh's post on Forrst. You can also find the code on github.

Also thanks to @ejetzer for suggesting a better way of selecting placeholder input elements.

Something went wrong with that request. Please try again.