jQuery Magic Labels Plugin

by Henrik Joreteg

Provides semantically clean solution for adding in-field labels.

This plugin checks the “for” property of the <label> field and inserts the content of the <label> tag as a placeholder value of the associated <input type="text"> or <textarea> fields.

Demo

Check out the demo.

Download

You can download the latest version of this project from GitHub. You can also clone the project with Git by running:

$ git clone git://github.com/HenrikJoreteg/jquery-magic-labels

Dependencies

jQuery 1.2.6 or later should work

Install

simply add the script reference after you import jquery:

<script src="jquery.js"></script>
<script src="jquery.magiclabels.min.js"></script>

Then call magicLabels() function with a selector identifying the form you want to use it on. Like this:

$(document).ready(function(){
    $("form").magicLabels();
});

NOTE: in this example I’m using “form”, but it can be any valid selector as long as it grabs forms you wish to apply the effect to.

License

BSD License