Change color of the text in contenteditable div

前端 未结 5 1831
春和景丽
春和景丽 2021-02-09 21:10

Demo is here

I have a contenteditable div. I want the functionality in the div as follows:

When I click on red anchor tag, the new text that I will write will be

5条回答
  •  梦谈多话
    2021-02-09 21:58

    Try this one. It works perfectly for me

    $("#red").click(function () {
    $('#my-contenteditable-div').html($('#my-contenteditable-div').html() + ' ');
    });
    
    $("#blue").click(function () {
    $('#my-contenteditable-div').html($('#my-contenteditable-div').html() + ' ');
    });
    

    Demo Here : https://jsfiddle.net/Saneesharoor/ftwbx88p/

提交回复
热议问题