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 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,801 Points

Hi there!

2months have passed since the question :)

How are you doing with your JavaScript?! ^^

2 Answers

Steven Parker
Steven Parker
231,271 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
231,271 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,385 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
231,271 Points

Thanks for the nice comments, and happy coding!