This works for inputs. I use this to admin panel my WP themes.
$ selectedColor is the previously saved value or the default value.
<input type="hidden" name="myColor" id="myColor" value="<?=$selectedColor?>"/> <div class="colorSelector" id="myColorPicker"> <div style="background-color: <?=$selectedColor?>"></div> </div> <script type="text/javascript"> jQuery(document).ready(function($){ jQuery('#myColorPicker').ColorPicker({ color: '<?=$selectedColor?>', onShow: function(colpkr) { jQuery(colpkr).fadeIn(500); return false; }, onHide: function(colpkr) { jQuery(colpkr).fadeOut(500); return false; }, onChange: function (hsb, hex, rgb) { jQuery('#myColorPicker div').css('backgroundColor', '#' + hex); jQuery('#myColor').val('#' + hex); } }); }); </script>
If you add it to the dialog, add more z-index to the colorpicker.
.colorpicker, .colorpicker * { z-index: 9999; }
source share