Written by Brian Vaughn
To use jQolor in a form
you simply need to assign a text-input as a color picker:
<input id="my-color-picker" name="my-color-picker" /> <script type="text/javascript"> $('#my-color-picker').jQolor(); </script>
The above code will create a jQolor selector like this:
The user-selected color will be passed to the form-handler as a HEX string on form-submit.
You can also attach an event-handler to a jQolor picker:
<input id="my-color-picker" name="my-color-picker" /> <script type="text/javascript"> $('#my-color-picker').jQolor( { color : '1C72B5', // Default color value colorChange : function( event, data ) { // data keys: hex, red, green, blue, hue, saturation, brightness } } ); </script>
This color picker has an event handler that modifies the graphic above it.
To do this it uses the data
object's "hex" property.
jQolor is available on Github under the Apache license. You can download it from Github directly or from the jQuery plug-ins site.
Please feel free to contact me on Github with questions, comments, or suggestions.