contentEditable div replace innerHTML on the fly

后端 未结 2 345
一生所求
一生所求 2021-01-21 17:34

Is there a way ( except Rangy library ) to change contentEditable Div InnerHTML on the fly, like on keyup, with no cursor position / focus lose? I\'d like to use pure javascript

2条回答
  •  清酒与你
    2021-01-21 17:51

    This doesn't use the keyup event but perhaps it will suffice? Note that applies to the body you can obviously target just a certain element.

    document.body.contentEditable='true';
    document.designMode='on';
    void 0;
    

提交回复
热议问题