html dom insertadjacenttext 28 29 method

Solutions on MaxInterview for html dom insertadjacenttext 28 29 method by the best coders in the world

showing results for - "html dom insertadjacenttext 28 29 method"
Mylan
10 Jan 2021
1<!DOCTYPE html>
2<html>
3<body>
4
5<h1>HTML DOM insertAdjacentText() Method</h1>
6
7<p>This method inserts a specified text, into a specified position.</p>
8
9<h2 id="myH2">My Header</h2>
10
11<p>Click the button to insert some text after the header:</p>
12
13<button onclick="myFunction()">Insert text</button>
14
15<script>
16function myFunction() {
17  var h = document.getElementById("myH2");
18  h.insertAdjacentText("afterend", "My inserted text");
19}
20</script>
21
22</body>
23</html>
24