JavaScript: querySelector

querySelector returns the first element that matches a CSS selector.

const button = document.querySelector('.button');

It returns null when nothing matches, so check the result before using it.