Answers for "how would you create a new h1 element with javascript"

0

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>
Posted by: Guest on May-20-2021

Code answers related to "how would you create a new h1 element with javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language