Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/amerikan/placeholder-polyfill

Add placeholders to your inputs and textareas in older browsers that don't support the placeholder attribute natively.
https://github.com/amerikan/placeholder-polyfill

jquery-plugin placeholder

Last synced: about 2 months ago
JSON representation

Add placeholders to your inputs and textareas in older browsers that don't support the placeholder attribute natively.

Awesome Lists containing this project

README

        

placeholder-polyfill
====================

A small jQuery plugin to show placeholders on HTML ``'s and ``'s in browsers that don't support the `placeholder` attribute natively.

## Demo
[Live Demo](http://amerikan.github.io/placeholder-polyfill) - the plugin take effect in only browsers that don't support the placeholder attribute natively

[Demo with forceMode option](http://amerikan.github.io/placeholder-polyfill/simulated.html) - the plugin will take effect in all browsers by force

## Requirements

Requires jQuery 1.0+

## Usage

First include the placeholder-polyfill plugin after your jQuery:

```html

```

Then initialize:

```html

$(function () {
$('input, textarea').placeholder();
});

```

```html

```

The plugin will then look for any `` and `` in your page that has the `placeholder` attribute set and add the placeholder functionality if the browser doesn't support it already natively already. See [Can I Use](http://caniuse.com/#feat=input-placeholder) to see what browsers support placeholder natively.

You can also pass options:
```html

$(function () {
$('input, textarea').placeholder({customClassName: 'my-placeholder'});
});

```

### Options Available
`customClassName`: class name of wrapper. `default value: placeholder`

`forceMode`: force a browser to use the plugin functionality even if it supports placeholder natively. Please note, that in such case you will need to use **placeholder-x** as an attribute rather than **placeholder**. This is mostly useful for debugging modern browsers. `default value: false`

## Bugs

The development of this plugin just started so it's fairly new. I welcome Pull Requests and bug reports.

Before opening an issue, please check if a similar issue is not already opened. When opening an issue please include:

- browser(s) affected
- test case for me to test
- jQuery version

## License

MIT