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 trialShane Ashford
14,705 PointsWhy is this add-attribute code not working?
I'm stuck and any help would be appreciated.
Here is my quiz question: Using jQuery only, add to all links with the class "external", the target attribute with the value of "_blank".
Here is my code: $( ".external a" ).attr( "target", "_blank" );
Here is the jQuery API on adding attributes:
$( "#greatphoto" ).attr( "title", "Photo by Kelly Clark" );
Teamtreehouse tells me "Bummer! I was expecting target
to be _blank
not ``"
1 Answer
rydavim
18,814 PointsYou've got the right idea, but your selector is in the wrong order. Right now you're looking for a
link tags inside the .external
tag. You want to look for links that are .external
. Hopefully that makes sense. :)
$( "a.external" ).attr( "target", "_blank" );
Happy coding!
Shane Ashford
14,705 PointsShane Ashford
14,705 PointsThanks so much rydavim! I was thrown off by the bummer response.