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

CSS jQuery Basics (2014) Creating a Simple Lightbox Perform: Part 4

Farid Lavizadeh
Farid Lavizadeh
12,006 Points

Why is 'captionText' not put as a jQuery representation?

Why is 'captionText' not put as a jQuery representation? In other words why doesn't it have a $ sign next to it?

2 Answers

geoffrey
geoffrey
28,736 Points

Caption text isn't a JQuery representation of an object, It's a simple string, no more. If you want to see it alive I setted up this little jsfiddle. Just open your console by pressing F12 and run the code. This will become obvious then.

the js fiddle here;

Sean T. Unwin
Sean T. Unwin
28,690 Points

captionText is a variable that's value the text of the clicked image's alt attribute. Therefore, it doesn't need to be a jQuery object.

I have answered another question from this lesson that may be a tangent of this question. Perhaps it may help make things a little more clear.