javascript - How to maintain the font color after inserting <br> tags in a contenteditable div? -


first of , in contenteditable div , if user presses enter , want have gap of line , therefore following code.

<div contenteditable="true" class="doc"></div> <script> $('.doc').keydown(function(e) {      if (e.keycode == 13) {        document.execcommand('inserthtml', false, '<br><br>');       return false;     }   }); </script> 

now , using tooltip ,which appears on double clicking word in div, if set font color red , remains red till press enter i.e. changes black press enter. wanted use same option change color red , same revert black, below.

i=0; function setcolor()         {              if(i==0)             {                 document.execcommand('forecolor',false,'#f00');                 i=1;             }             elseif(i==1)             {                 document.execcommand('forecolor',false,'#000000');                 i=0;             }                          } 

but not works desired , font color changes black press enter instead of changing when again press option in tooltip.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -