As per mozilla documentation about execCommands:
foreColor:
Changes a font color for the selection or at the insertion point. This requires a color value string to be passed in as a value argument.
So in your code, even if you select anything from the contenteditable, once you click on colorpicker button, your selection is lost so your execCommand doesn't work. You can check for the selected text using console and it shows that no text is selected.
Here is the code test:
var colorpickerOptions = {
select: function (event, color) {
var color_in_hex_format = color.formatted;
console.log(window.getSelection().toString());//Checks for selected text
//document.execCommand('foreColor', false, '#'+color_in_hex_format);
$('[contenteditable]').css('color', '#' + color_in_hex_format);
$('.colorpicker').css('background-color', '#' + color_in_hex_format);
},inline: false
};
$('.colorpicker').colorpicker(colorpickerOptions);
So, the simple solution will be to either apply the color
css to complete div like:
$('[contenteditable]').css('color', '#' + color_in_hex_format);
by replacing the execCommand
line with the above line.
Demo : http://jsfiddle.net/lotusgodkk/6V7hL/144/
PS: I didn't downvote your question.