Dynamically insert a standard element

by snifty

HTML

<!doctype html>
<title>Add a heading</title>
<button>click me!</button>

JavaScript

document.querySelector('button').onclick = () => {
  let h1 = document.createElement('h1')
  h1.textContent = 'I’m an h1!'
  document.body.append(h1)
}