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 2

Question regarding single/dubbel quote markes

//Working code:
$('<div id="overlay"></div>');


//Non-working code:
$("<div id="overlay"></div>");

We are using single quotes on the whole Parentheses and dubble on overlay. I had some problems with that for a couple of minutes. Basically the quotes crash with each-other and sets overlay without quote, is that why we use different marks?

1 Answer

James Tench
James Tench
43,891 Points

Yes this is why you would use different types of quote marks. In the second example, the second double quote is ending a string of text. The third and fourth quotes are wrapping another string of text. That leaves the word overlay in the middle alone.