how would you create a new h1 element with javascript

Solutions on MaxInterview for how would you create a new h1 element with javascript by the best coders in the world

showing results for - "how would you create a new h1 element with javascript"
Nora
02 May 2020
1<!DOCTYPE html>
2<html>
3<body>
4
5<p>Click the button to create a h1 element with some text.</p>
6
7<button onclick="myFunction()">Click to create</button>
8
9<script>
10function myFunction() {
11    var myStyle = document.createElement("H1");
12    var myText = document.createTextNode(prompt("This is an example of text written in H1");
13    h.appendChild(myText);
14    document.body.appendChild(myStyle);
15}
16</script>
17
18</body>
19</html>
20