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

Adam Dunlap
PLUS
Adam Dunlap
Courses Plus Student 2,520 Points

Using jquery to manipulate elements and add behavior - Task 2/3

I'm having a bit of trouble figuring out whats going on here. The code provided is this:

$(".error").show();
$("a")

With the instruction to: "Before every link add the HTML "<span>This is a link: </span>".

So I tried:

$(".error").show();
$("a").before("<span>This is a link: </span>");

I'm not sure if that is the correct code or not, but the '/span>");' turns orange, and when I check my work, it tells me that Task 1 is no longer passing.

Task 1 was adding .show(); to $(".error").

How does task 2 make task 1 no longer pass? and why does the closing span tag turn orange, and why does it turn orange at the / instead of the < ?

Lots of thanks in advance for any help, I know its a lot of questions :D

7 Answers

Andrea Kotys
Andrea Kotys
7,396 Points

In case anyone gets stuck on this for 20 minutes like i did..... $(".error").show(); $("a").before("<span>This is a link: </span>"); is the correct code.

$(".error").show();
$("a").before("<span>This is a link:</span>");

$(".error").show();
$("a").before("<span> This is a link: </span>");

$(".error").show();
$("a").before("<span> This is a link:</span>");

will all not work.... ie. the <span> spacing

Phil Rice
Phil Rice
5,536 Points

i just had exactly the same problem as Adam - i checked and rechecked the code and it was exactly the same (im sure). So i tried cutting and pasting the code adam put and it worked! unless i really did something wrong that i missed it could be a bug in this one.

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Hi Adam,

I don't know why it's not passing I copied and pasted your code and I am on task 3 now. Can you try it again?

Regards

Andrew

Phil Rice
Phil Rice
5,536 Points

Hi Andrew Chalkley , on the pc i was using when i got this problem I was using windows 8 pro 64 bit and chrome Version 26.0.1410.64 m.

Andrea Kotys
Andrea Kotys
7,396 Points

yes i am. windows 8

Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

Did you copy and paste the code or type it in? Also try without a return and see if it works.

Have to agree with Phil on this I kept getting the same error message. When i Typed it did not work , when I copied and pasted all of a sudden o problems same code.