Skip to content

Instantly share code, notes, and snippets.

@seedprod
Created August 30, 2011 16:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save seedprod/1181262 to your computer and use it in GitHub Desktop.
Save seedprod/1181262 to your computer and use it in GitHub Desktop.
WordPress Color Picker
<input type="text" name="my-theme-options[color]" id="color" />
<input type='button' class='pickcolor button-secondary' value='Select Color'>
<div id='colorpicker' style='z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;'></div>
// Color Picker for js file
$('.pickcolor').click( function(e) {
colorPicker = jQuery(this).next('div');
input = jQuery(this).prev('input');
$(colorPicker).farbtastic(input);
colorPicker.show();
e.preventDefault();
$(document).mousedown( function() {
$(colorPicker).hide();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment