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 trialMohammed Munier Hamoud Shikh
1,616 PointsIn 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'
2 Answers
Steven Parker
231,236 PointsI 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
44,857 PointsAny idea why they return the tagName in uppercase? That seems really inconsistent with the rest of the functions in JS.
Steven Parker
231,236 PointsThis is a legacy from the early development of HTML (it was derived from SGML), when tags were conventionally written in upper case.
Stanlon Milow
22,385 PointsSteven 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
231,236 PointsThanks for the nice comments, and happy coding!
Aurelian Spodarec
10,801 PointsAurelian Spodarec
10,801 PointsHi there!
2months have passed since the question :)
How are you doing with your JavaScript?! ^^