JavaScript JavaScript and the DOM Responding to User Interaction Event Delegation

Davindar Singh
Davindar Singh
1,951 Points

What does E mean in this code ""

This is the question

"In the listener that has been added to the section element, ensure that the text input elements are the only children"

I am assuming it's a section, but I could not see such a section in the index.html file

This is the answer I found in the community

if ( == 'INPUT') {

In the listener that has been added to the section element, ensure that the text input elements are the only children

<!DOCTYPE html>
        <title>JavaScript and the DOM</title>
    <link rel="stylesheet" href="style.css" />
            <h1>Making a Webpage Interactive</h1>
            <p>JavaScript is an exciting language that you can use to power web servers, create desktop programs, and even control robots. But JavaScript got its start in the browser way back in 1995.</p>
            <p>Things to Learn</p>
                <li>Item One: <input type="text"></li>
                <li>Item Two: <input type="text"></li>
                <li>Item Three: <input type="text"></li>
                <li>Item Four: <input type="text"></li>
        <script src="app.js"></script>
let section = document.getElementsByTagName('section')[0];

section.addEventListener('click', (e) => {
    if ( == 'input') { = 'rgb(255, 255, 0)';

2 Answers

Jennifer Nordell
Jennifer Nordell
Treehouse Staff

Hi there, Davindar Singh ! The "e" is a common naming convention for the Window.event object. You are accessing the target property on that. Now the question might be why not use And you could, but if you use Firefox you will still have to pass in the event explicitly. Microsoft made the Window.event object global in Edge, Google followed suit with Chrome, and Apple then followed with Safari. So if you had something like:

section.addEventListener('click', () => {  // here we don't pass in the event object
    if ( == 'input') { = 'rgb(255, 255, 0)';

It should still work in Edge, Chrome and Safari, but it will not work in Firefox and will throw errors telling you that event is undefined. So we need to pass in that event. You could rewrite it without the "e" as event and that would also work, but you do need to pass in the event. So you could rewrite that as:

section.addEventListener('click', (event) => {  // here we pass in the event object
    if ( == 'input') { = 'rgb(255, 255, 0)';

Here's a bit of short documentation on Window.event, though somewhere I found a more detailed explanation once, but cannot find it again right now.

Also, I believe the "section" they are referring to are the <section></section> tags that start before the <h1> and end after the <button>.

Hope this helps!

Pro Student 47,271 Points

e means event. is the element that triggered the event.