A basic jQuery plugin that reads the "placeholder" attribute (HTML5) and renders the placeholder text as an overlay (if not natively supported). Unlike most other plugins, this works by adding a properly-positioned <span>
on top of the input element rather than setting its value. This keeps form serialization & validation from breaking.
$('input,textarea').placeholder();
Check out the demos!
Option | Type | Default | Description |
---|---|---|---|
force | bool |
false |
If true , artificial placeholder elements will be added even if the browser natively supports them. |
.placeholder { color: #d0d0d0; }
::-webkit-input-placeholder { color: #d0d0d0; }
input:-moz-placeholder, textarea:-moz-placeholder { color: #d0d0d0; }
Copyright © 2012 DIY Co
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.