Change color of the text in contenteditable div

前端 未结 5 1828
春和景丽
春和景丽 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:59

    Please try this

    $("#red,#blue").click(function () {
        $new = $("
    ", { class: $(this).attr('id'), contenteditable : 'true' }) $("#my-contenteditable-div") .append($new) .children('div:last').focus(); });

    DEMO

提交回复
热议问题