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

help with Using jQuery to Manipulate Elements and Add Behavior

i was trying to do exercise but i don't understand where i am doing wrong

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

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

i am getting this alert"Bummer! Incorrect string passed in to the before method. Please check it and try again."

i am just a beginner.sorry it is easy but can't figure out

5 Answers

Close! You need to remember to add the span tags in (otherwise it'd just be plain text sitting in the document), and I'm not sure why you have that extra $("a") at the end, you don't need that:

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

This will select every "a" element in the document, and before it add the span code.

thanks for answering..i forgot to close span :)

I had the same problem as Ozlem, the instructions leading up to this exercise are not just bad, but incomplete.

It would be really helpful if there was some more time spent on why/how and syntax before this exercise. This site is also in dire need of Hints during the exercises.

I agree with Chris; nearly every lesson thus far has been like jump in the deep end and swim (if you know how). More time needs to be spent with clear and concise explanations.

I am in the same boat. I'm yet to get through all the steps of a code challenge without having to google for an answer.