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 trialBryan Castleman
9,520 PointsWhy are singular quotation marks used when assigning a variable to a div ?
in the following: var $overlay = $(' ') ?
1 Answer
Jason Anello
Courses Plus Student 94,610 PointsHi Bryan,
In this case single quotes were used to wrap the string because it contains double quotes which were used for the id
attribute.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsYou could wrap with double quotation marks on the outside but then you have to escape the double quotations marks on the inside with a backslash
\
var $overlay = $("<div id=\"overlay\"></div>");
This is coming at the expense of readabilityAlternatively, you can use double quotes on the outside and single quotes on the inside:
var $overlay = $("<div id='overlay'></div>");
Bryan Castleman
9,520 PointsBryan Castleman
9,520 PointsI see. Thanks for clearing that up.