How to insert HTML element and text in specific position with JavaScript

1 Answer

0 votes
<!DOCTYPE html>
<html>
<body>
<h1 id="h1_id">H1</h1>
<script>
   var element = document.getElementById("h1_id");
   element.insertAdjacentHTML("afterend","<p>Paragraph</p>");
</script>
</body>
</html>


<!--

H1

Paragraph

-->

 



answered Oct 26, 2019 by avibootz
...