[Solved] Buttons in HTML/Javascript [closed]


Use .innerHTML to replace elements within a DOM object.

function ReplaceText(){
  document.getElementById("mytext").innerHTML = "My new text";
}
<html>

  <head>
  </head>

  <body>

    <div id="mytext">
      My text
    </div>

    <button id="replace" onclick="ReplaceText()"> Replace Text </button>

  </body>

</html>

solved Buttons in HTML/Javascript [closed]