How can I log smt to the console on button click?

I m trying something really simple: I have tree buttons and I want to log smt to the console when clicked.

HTML

<div id="button-box">
<button data-id="244">Eins</button>
<button data-id="943">Zwei</button>
<button data-id="143">Drei</button>
</div>

Javascript

// selector
    const buttonBox = document.getElementById('button-box');

// eventlistener
    buttonBox.addEventListener('click', event => {
    console.log("button clicked");
});

I m getting the following error:

Uncaught TypeError: Cannot read properties of null (reading ‘addEventListener’)

Grateful for any tipps.