Change color of the text in contenteditable div

前端 未结 5 2020
陌清茗
陌清茗 2021-02-09 21:24

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:56

    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/

提交回复
热议问题