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 Perform: Part 3

Perform 3 Challenge 1 unable to get correct solution

My HTML Code: <!DOCTYPE html> <!-- saved from url=(0088)https://preview.treehouse-challenges.com/ad87a07c-460f-40af-87aa-dc24f1bd35fa/index.html --> <html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8"> <title>Links Page</title> </head> <body> <h1>Links</h1> <ul id="externalLinks"> <li><a href="http://google.com/" class="external">Google</a></li> <li><a href="http://yahoo.com/" class="external">Yahoo</a></li> </ul> <script src="jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script> <script src="app.js" type="text/javascript" charset="utf-8"></script>

Added code on line 9 - id="externalLinks"

app.js code:

var $trgt = $(target = "_blank"); $("#externalLinks a").click(function(event)) { event.preventDefault(); $(".external").append.attr($trgt); }

Syntax error!!

Thanks for the help. John

8 Answers

Qasim Hafeez
Qasim Hafeez
12,731 Points

$('li a').attr('target', '_blank');

I got it thanks to a Google search!!

Fernando Zegarra
Fernando Zegarra
Courses Plus Student 2,596 Points

If it possible, could you tell me what was your solution

So as far as I can tell from the code you have provided there is one error. You have placed your curly braces for the anonymous function in the wrong place. Your Code should look like this:

$("#externalLinks a").click(function(event){

event.preventDefault();

$(".external").append.attr($trgt);

});

That's what I think anyway try it out. Notice that the curly braces for your anonymous function are placed right after the (event) parameter and the closing ) for your .click(function comes after the closing }. Let me know if that fixes your issue if not I'm going to need more information.

Btw the spaces between the code inside the click function are unnecessary just added them in for readability .

Bo Christensen
Bo Christensen
5,924 Points

I hope your found your solution. The problem is that $(".external").append.attr($trgt); will look like this when $(".external").append.attr(target = "_blank"); where it should look like this ('target', '_blank')

Fernando Zegarra
PLUS
Fernando Zegarra
Courses Plus Student 2,596 Points

$("ul li").children(".external").attr('target', '_blank');

jough
jough
12,984 Points

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

thx, still could not get it to work.Error message "You didn't set the 'target' attributes on the 'external' links"

did someone solved it? i cant figure it out i hate this teacher so much..

Fernando Zegarra
Fernando Zegarra
Courses Plus Student 2,596 Points

$("ul li").children(".external").attr('target', '_blank');