感谢您的帮助Sally,这是完整的jQuery,它将RGB值推送到另一个字段。RGB字段的名称_rgb
在最后。
jQuery(function() {
var myOptions = {
// you can declare a default color here,
// or in the data-default-color attribute on the input
defaultColor: false,
// a callback to fire whenever the color changes to a valid color
change: function(event, ui){
var rgb = ui.color.toCSS( \'rgb\' );
var name = jQuery(this).attr("name");
name = \'#\' + name + \'_rgb\';
jQuery(name).val(rgb);
},
// a callback to fire when the input is emptied or an invalid color
clear: function() {},
// hide the color picker controls on load
hide: true,
// show a group of common colors beneath the square
// or, supply an array of colors to customize further
palettes: true
};
jQuery(\'.color-field-custom\').wpColorPicker(myOptions);
});
下面是颜色选择器字段下面的自定义字段。
<input type="text" name="destination_secondary_color_rgb" id="destination_secondary_color_rgb" value="<?php echo get_post_meta($post->ID, \'destination_secondary_color_rgb\', true); ?>" />