<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>可编辑表格 &lt;input&gt; 示例</title>
  <style>
    textarea {
      height: 80px;
      background-color: #F4F7F8;
      border: none;
      border-left: 6px solid #558ABB;
      color: #4D4E53;
      width: 90%;
      max-width: 700px;
      padding: 10px 10px 0px;
    }

    .playable-buttons {
      text-align: right;
      width: 90%;
      max-width: 700px;
      padding: 5px 10px 5px 26px;
    }

    section {
      width: 90%;
      max-width: 700px;
      border: 1px solid #4D4E53;
      border-radius: 2px;
      padding: 10px 14px 10px 10px;
      margin-bottom: 10px;
    }

    section input {
      display: block;
      margin: 5px;
    }
  </style>
</head>

<body>
  <section>
  </section>

  <textarea id="code" class="playable-code">
<input id="input1" type="text">
<input id="input2" type="text">
</textarea>

  <div class="playable-buttons">
    <input id="reset" type="button" value="重置">
  </div>

  <script>
    const section = document.querySelector('section');
    const textarea = document.getElementById('code');
    const reset = document.getElementById('reset');
    const edit = document.getElementById('edit');
    const code = textarea.value;

    function fillSection() {
      while (section.firstChild) {
        section.removeChild(section.firstChild);
      }
      section.innerHTML = textarea.value;
    }

    reset.addEventListener('click', function() {
      textarea.value = code;
      fillSection();
    });

    textarea.addEventListener('input', fillSection);
    window.addEventListener('load', fillSection);
  </script>
</body>
</html>
