create element javascript h1 code example
Example: how would you create a new h1 element with javascript
<!DOCTYPE html>
<html>
<body>
<p>Click the button to create a h1 element with some text.</p>
<button onclick="myFunction()">Click to create</button>
<script>
function myFunction() {
var myStyle = document.createElement("H1");
var myText = document.createTextNode(prompt("This is an example of text written in H1");
h.appendChild(myText);
document.body.appendChild(myStyle);
}
</script>
</body>
</html>