Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript and the DOM (Retiring) Responding to User Interaction Event Delegation

In listener added to the section element, ensure that the text input elements are the only children to trigger change.

Does anyone have the solution to this? I have the following but it doesn't work: if (e.target == "INPUT") { ...

2 Answers

Steven Parker
Steven Parker
231,269 Points

You probably want to test the tagName.

The target attribute would give you a reference to the target element itself, but you can't successfully compare that directly to a string. You probably want e.target.tagName instead.

if (e.target.tagName == "INPUT") { ...

Apologies.

I did put just that: if (e.target.tagName == "INPUT") { ...

Yet I didn't pass the test.

Steven Parker
Steven Parker
231,269 Points

It works for me. Did you remember to put a closing brace on the other side of the statement?

If that's not it, it might help if you show your complete code.