document .querySelector('button') ?.addEventListener('click', event => console.log((event.target as Element).textContent) );