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!
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

Alexey Tseitlin
5,866 PointsjQuery beginner ".each()"
Why do I get an error in the console? "Uncaught SyntaxError: Unexpected token ;"
$("#menu a").each(function(){
console.log(($this.attr("href"));
});
<body>
<div id="menu">
<ul>
<li class="selected"><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="support.html">Support</a></li>
<li><a href="faqs.html">FAQs</a></li>
<li><a href="events.html">Events</a></li>
</ul>
</div>
2 Answers

James Spence
17,563 PointsYou made a typo with 'this', your code should read:
$("#menu a").each(function(){
console.log($(this).attr("href"));
});

Brian Romine
9,518 PointsJames has it. "Unexpected token" errors are SUPER common, always carefully check over your brackets and parentheses carefully. It nearly always means you have some tiny syntactic error.