InputLabel jQuery Plugin demos
The inputLabel jQuery plugin uses a passed in string or a reference form label text to insert a "placeholder" text inside a form input field.
jQuery.inputLabel(text,opts) paramenters:
- text:Initial value of the field. Can be either a string, a jQuery reference (example: $("#element")), or boolean false (default) to search for related label
- options: object
- color: initial text color (default : "#666")
- e: event which triggers label text clearing (default: "focus")
- force: execute this script even if input value is not empty (default: false)
- keep: if value of field is empty on blur, re-apply label text (default: true)
Demo HTML
<label for="myInput">Enter a value</label> <input type="text" name="myInput" id="myInput" />
Basic Usage
$("#myInput").inputLabel();
Custom text
$("#myInput").inputLabel("Custom label text");
$("#myInput").inputLabel($("#header h1")); //get the text from a DOM element
Run the script just once
$("#myInput").inputLabel(false,{keep:false});
Custom text color
$("#myInput").inputLabel(false,{color:"#F00"}); //red color
Run the script even if the field has a defined value attribute
<label for="myInput">Enter a value</label>
<input type="text" name="myInput" id="myInput" value="pre-filled value" />
force:false (default)
$("#myInput").inputLabel(false,{force:true});
force:true
