Javascript

 InnerHTML

Outerhtml

<button onclick="myFunction()">Change</button>


<script>

function myFunction() {

  const element = document.getElementById("myP");

  element.outerHTML = "<h2>This is a h2 element.</h2>";

}

</script>


<script>

function myFunction() {

  const element = document.getElementById("myP");

  element.outerHTML = "<h2>This is a h2 element.</h2>";

}

</script>

Comments

Popular posts from this blog

Petroleum