How to clear wpColorPicker (Iris.js)?

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"?

Topic color-picker Wordpress

Category Web


This is hacky but gets the job done.

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

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.