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()

dawoon chung
dawoon chung
3,962 Points

I can't solve this

My code as below, can you help me to solve this?

var $target = $("<target = '_blank'>"); $(".external a").attr($target)

2 Answers

Not a bad start you just need to reorder your arguments. First the question is asking you to take all links with the class external and create a target with the name _blank.

Like in the question you start with the anchor links with the class external then apply the attribute method. the attr takes two arguments, the attribute name and value. Here target is the attribute name and _blank is the value. take a look at the code below:

$("a.external").attr("target" , "_blank");
dawoon chung
dawoon chung
3,962 Points

Gotcha! Thanks a lot!! Have a good day.

Any time!