| Number of watchers on Github | 4145 |
| Number of open issues | 28 |
| Average time to close an issue | 3 months |
| Main language | JavaScript |
| Average time to merge a PR | 10 days |
| Open pull requests | 2+ |
| Closed pull requests | 33+ |
| Last commit | over 2 years ago |
| Repo Created | over 9 years ago |
| Repo Last Updated | over 1 year ago |
| Size | 128 KB |
| Homepage | https://mths.be/p... |
| Organization / Author | mathiasbynens |
| Latest Release | v2.3.1 |
| Contributors | 21 |
| Page Updated | 2018-03-12 |
| Do you use jquery-placeholder? Leave a review! | |
| View open issues (28) | |
| View jquery-placeholder activity | |
| View on github | |
| Fresh, new opensource launches πππ | |
|
Trendy new open source projects in your inbox!
View examples
|
|
https://mathiasbynens.github.io/jquery-placeholder/
<input type="text" name="name" placeholder="e.g. John Doe">
<input type="email" name="email" placeholder="e.g. [email protected]">
<input type="url" name="url" placeholder="e.g. https://mathiasbynens.be/">
<input type="tel" name="tel" placeholder="e.g. +32 472 77 69 88">
<input type="password" name="password" placeholder="e.g. h4x0rpr00fz">
<input type="search" name="search" placeholder="Search this site">
<textarea name="message" placeholder="Your message goes here"></textarea>
Use the plugin as follows:
$('input, textarea').placeholder();
By default, .placeholder css class will be added. You can override default by passing the customClass option:
$('input, textarea').placeholder({ customClass: 'my-placeholder' });
Youll still be able to use jQuery#val() to get and set the input values. If the element is currently showing a placeholder, .val() will return an empty string instead of the placeholder text, just like it does in browsers with a native @placeholder implementation. Calling .val('') to set an elements value to the empty string will result in the placeholder text (re)appearing.
The plugin automatically adds class="placeholder" to the elements who are currently showing their placeholder text. You can use this to style placeholder text differently:
input, textarea { color: #000; }
.placeholder { color: #aaa; }
Id suggest sticking to the #aaa color for placeholder text, as its the default in most browsers that support @placeholder. If you really want to, though, you can style the placeholder text in some of the browsers that natively support it.
You can install jquery-placeholder by using Bower.
bower install jquery-placeholder
Or you can install it through npm:
npm install --save jquery-placeholder
Contributors should install the dev dependencies after forking and cloning via npm.
npm install
placeholder attribute for input and textarea elements. If this is the case, the plugin wont do anything. If @placeholder is only supported for input elements, the plugin will leave those alone and apply to textareas exclusively. (This is the case for Safari 4, Opera 11.00, and possibly other browsers.)jQuery.fn.placeholder.input and jQuery.fn.placeholder.textarea. For example, if @placeholder is natively supported for input elements, jQuery.fn.placeholder.input will be true. After loading the plugin, you can re-use these properties in your own code.<input type="reset" /> will break the plugin functionality Makes sure it never causes duplicate IDs in your DOM, even in browsers that need an extra input element to fake @placeholder for password inputs. This means you can safely do stuff like:
<label for="bar">Example label</label>
<input type="password" placeholder="foo" id="bar">
And the <label> will always point to the <input> element youd expect. Also, all CSS styles based on the ID will just work.
This plugin is available under the MIT license.
_ Mathias_
hidden] inputs by using [type=
hidden] rather than :hidden
Fixed javascript:void(0) anchor usage from breaking the plugin