https://github.com/mudge/jquery_placeholder
A jQuery plugin to support HTML5's placeholder attribute in older browsers.
https://github.com/mudge/jquery_placeholder
Last synced: about 1 year ago
JSON representation
A jQuery plugin to support HTML5's placeholder attribute in older browsers.
- Host: GitHub
- URL: https://github.com/mudge/jquery_placeholder
- Owner: mudge
- License: mit
- Created: 2009-10-08T21:38:59.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2011-11-30T07:45:06.000Z (over 14 years ago)
- Last Synced: 2025-05-08T22:42:20.091Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 95.7 KB
- Stars: 15
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE.txt
Awesome Lists containing this project
README
jQuery Placeholder Plugin
=========================
A plugin to make HTML5's [`placeholder`][placeholder_spec] attribute work in non-HTML5
browsers.
This started as an attempt to simplify [my jQuery Form Example plugin][jquery_example]
by delegating functionality to the browser where possible.
[placeholder_spec]: http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#the-placeholder-attribute
[jquery_example]: http://github.com/mudge/jquery_example
Usage
-----
Simply use the `placeholder` attribute on your `input` and `textarea` tags and include
`jquery.placeholder.js` somewhere in your page (you'll need [jQuery][jquery] as well, of course).
e.g.
[jquery]: http://jquery.com/
Placeholder values in non-HTML5 browsers will be given the CSS class of `jquery_placeholder` so
you can style them to mimic other browsers' defaults which for Safari seems to be something
like the following:
.jquery_placeholder { color: #aaa; }
If you want to customise the class name used, you'll have to stop the plugin from
automatically running itself by commenting out `$($.placeholder.backwardsCompatibility);`
towards the end of `jquery.placeholder.js`. You can then set the class name via
`$.placeholder.className` and call `backwardsCompatibility()` yourself.
e.g.
$.placeholder.className = 'myPlaceholderCSSClass';
$.placeholder.backwardsCompatibility();
All event handlers are namespaced with `.placeholder` so they can be unbound or
triggered selectively:
* `unload.placeholder` on the window;
* `blur.placeholder` on the affected inputs;
* `focus.placeholder` on the affected inputs;
* `change.placeholder` on the affected inputs;
* `submit.placeholder` on the affected forms.
Licensing
---------
Copyright (c) Paul Mucur (http://mudge.name), 2010-2011.
Licensed under the MIT license (see LICENSE.txt).