문제

Trying to call execCommand after color selection:

$('#picker').colorPicker(
    {           
      defaultColor:0, // index of the default color
      columns:13,     // number of columns 
      click:function(c){
             document.execCommand('ForeColor',false, c);    
      }
});

but nothing happens. If i replace execCommand with $('#output').html(c) i see that call is successful.

example: http://jsfiddle.net/YQQXV/12/

ColorPicker plugin page

도움이 되었습니까?

해결책

I played a bit with you fiddle, incorporating an answer from here.

A more working example of your fiddle is here.

It seems to me as if you forgot the designMode setting.

다른 팁

According to MS Docs you need to pass a command ID as the first argument to execCommand. Where is your ForeColor pointing to?

$('#output').html(c) 

directly changes the inner HTML of the div with ID output, that's why it works.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top