Create a clickable list of numbers, updating the title text with the clicked number.

HTML

<h1 id="out">None</h1>
<section id="target"></section>

CSS

button {
  padding: 10px;
}

JavaScript

const out = document.getElementById('out')
const container = document.getElementById('target')

container.addEventListener('click', e => {
  if (e.target.tagName != 'BUTTON') return

  out.innerText = e.target.innerText
})

for (let i = 0; i<10; i++) {
  const el = document.createElement('button')
  el.innerText = i
  container.appendChild(el)  
}