JSFiddle - React, Tailwind, and code Playground

by YiuJia

HTML

<html>
  <head></head>
  
  <body>

    <div id="editor" contentEditable="true"></div>

    <div>
        <button type="button" id="restore">Restore</button>
    </div>
  </body>
</html>

CSS

#editor {
    width: 500px;
    height: 300px;
    padding: 10px;
    border: 1px solid #000;
    margin: 20px auto;
}

JavaScript

function restore() {
    var text = document.getElementById('editor');
    text.innerHTML = '<div>lorem <b>ipsum</b> test données</div><div><br></div>Voilà';
    return false;
}

var btnRestore = document.getElementById('restore');
btnRestore.addEventListener('click', restore);