Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript and the DOM Responding to User Interaction The Event Object

Mohammed Munier Hamoud Shikh
Mohammed Munier Hamoud Shikh
1,616 Points

In the Event Object lesson , Why you user event.target.Name=='LI', not 'li'

In the Event Object lesson , Why you user event.target.Name=='LI', not 'li'

Aurelian Spodarec
Aurelian Spodarec
10,789 Points

Hi there!

2months have passed since the question :)

How are you doing with your JavaScript?! ^^

2 Answers

Steven Parker
Steven Parker
208,481 Points

I think you mean "tagName" instead of just "Name", and for HTML documents, "tagName" returns the element name in the uppercase form. So the test compares it with "LI" to check for a match.

See the documentation for Element.tagName for more information.

Kyle Case
Kyle Case
44,857 Points

Any idea why they return the tagName in uppercase? That seems really inconsistent with the rest of the functions in JS.

Steven Parker
Steven Parker
208,481 Points

This is a legacy from the early development of HTML (it was derived from SGML), when tags were conventionally written in upper case.

Stanlon Milow
Stanlon Milow
22,373 Points

Steven Parker You are the man! I was so lost on why tagName returns all capitals but now it makes complete sense. It's legacy that things returned were in capital form so that's why this returns it in "LI". Thank you because I was lost. haha

Steven Parker
Steven Parker
208,481 Points

Thanks for the nice comments, and happy coding!