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 jQuery Basics (2014) Creating a Simple Lightbox Adding New Attribute Values with attr()

Corey Gilmore
Corey Gilmore
3,649 Points

I'm not sure why this doesn't work: $(".external a").attr("target", "_blank");

It's saying, "I was expecting '_blank' not ' ' " as the error message in the quiz. Searches online have some people using .attr({target: "_blank"}); but this returns the same error and essentially isn't different than what I have (it's usually used for setting several attributes at once).

Thanks

2 Answers

Jake Lundberg
Jake Lundberg
13,965 Points

You just have your class and element selector backwards. As you have it now, you're selecting all the a elements INSIDE of elements with the class .external...

The directions are asking for all a elements with the class .external, so you would write that as:

$("a.external").attr("target", "_blank");

Hope this helps!

Corey Gilmore
Corey Gilmore
3,649 Points

Ohhhhhhhh! I see the difference. Ok. Thanks!