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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Yoan Herrera](https://secure.gravatar.com/avatar/71aefcf3c82d426b7114cf3121331f1d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Yoan Herrera
21,137 Pointssaving a string in a jQuery selector??
Any specific reason why the instructor is saving the label html in a $(''). Using just a plain string const checkbox = "<label><input type='checkbox'> Allow PDF downloads</label>"
1 Answer
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsPassing the HTML string to jQuery creates a new element. Now, it happens that the .append
method will take either an element or a string as an argument, so it will work either way, but having an element might be handy in case you wanted to perform some other function on it. You might want to add a class or other attribute to it, for example.
Yoan Herrera
21,137 PointsYoan Herrera
21,137 PointsAwesome.. Thank you. makes sense.! y the way. do you know how to format code snippets, so it doens't look all jumbled together when posting a question??
Steven Parker
230,688 PointsSteven Parker
230,688 PointsSure, formatting is done with "Markdown" code. You can find a Markdown Cheatsheet pop-up below the "Add an Answer" area.
Or watch this video on code formatting.
Happy coding!
Yoan Herrera
21,137 PointsYoan Herrera
21,137 PointsThank you