search

Home  >  Q&A  >  body text

javascript - How to clear tags and styles of text pasted into editable (contenteditable) elements?

When copying text from other places, even the styles are copied. How to clear the original tags and styles?

黄舟黄舟2781 days ago888

reply all(2)I'll reply

  • 三叔

    三叔2017-06-30 09:55:13

    Open Notepad, paste, then select all, cut, and then copy.

    reply
    0
  • 黄舟

    黄舟2017-06-30 09:55:13

    Reference: https://stackoverflow.com/que...
    Example: (may not open)
    http://jsfiddle.net/ch6yn/

    The following is an example I wrote myself:

    <p id="editArea" contenteditable oninput="this.innerHTML = this.innerText">
    </p>

    reply
    0
  • Cancelreply