JSFiddle - React, Tailwind, and code Playground

HTML

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>innerText vs innerHTML Demo</title>
</head>
<body>
  <h2 id="demo">這裡是原始文字</h2>

  <button onclick="useInnerText()">使用 innerText</button>
  <button onclick="useInnerHTML()">使用 innerHTML</button>

  <script>
    function useInnerText() {
      document.getElementById("demo").innerText = "<b>粗體文字</b>";
    }

    function useInnerHTML() {
      document.getElementById("demo").innerHTML = "<b>粗體文字</b>";
    }
  </script>
</body>
</html>