JavaScript DOM Scripting By Example Editing and Filtering Names Filter Invitees Who Have Not Responded

How does works?

Hi everyone, I have one question about I cannot understand how it works. I mean, how the browser can recognize that we mean that is "input"? Couldn't it be instead "li" or "another tag?? Is there a way to associate to a specified tag? Thanks

1 Answer

Steven Parker
Steven Parker
186,894 Points

The event target is the element that created the event.

The browser doesn't care if it was an INPUT or LI or some other tag. But for your code to receive the event at all, you must have established an event listener on the target element or on an "ancestor" element. So you can associate the event target with a specific element by how you establish the listener(s).

In this video, for example, an event listener is added to the filter check box. So when that event occurs, we know that will contain a reference to that check box element.