what is eventListener? how does it work? for example this codebyte
const submit = document.querySelector('#submit'); submit.addEventListener('click', displaySuggestions);

The code says to put the element that has an id of submit as the submit variable.
An eventListener is that the element is “listening” for a specific event, and when that event occurs a specific function will be executed.

Here, an event listener is being added to the element in the submit variable. The event is a click. The function that will be executed is displaySuggestions.

When the “submit” element is clicked, run the displaySuggestions function.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.