1

I'm trying to clear the WordPress colorpicker but seems it doesn't work. This is what I'Ve tried:

$('#element').wpColorPicker('clear');
//error: Uncaught Error: no such method 'clear' for wpColorPicker widget instance
$('#element').wpColorPicker('color', '#');
//no output/change  
$('#element').wpColorPicker('color', '');
//no output/change

Of course there's no method mentioned in the documentation but there's a options for a callback method so it's maybe possible via some "hacking"?

6
  • How about this documentation. make.wordpress.org/core/2012/11/30/new-color-picker-in-wp-3-5
    – matthew
    Commented Sep 4, 2015 at 16:46
  • not really helpful in this case
    – Xaver
    Commented Sep 4, 2015 at 17:03
  • Do you see any errors in your console? Commented Sep 4, 2015 at 17:32
  • not really, I've updated my question
    – Xaver
    Commented Sep 4, 2015 at 17:36
  • Please add more code. How do you trigger the wpColorPicker? On document_ready handler? Additionally please ensure if jquery enqueued before colorpicker scripts and both libs loads well.
    – Ignat B.
    Commented Sep 4, 2015 at 20:53

1 Answer 1

1

This is hacky but gets the job done.

$('#element .wp-picker-clear').trigger('click');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.