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 trialZachary Eckstein
9,901 PointsWhat am I missing? I am sure it is something simple that I should be able to easily remember...
I don't know why this is failing. Can you just point out what I am getting wrong here? I'll remember the correct answer and not ask about this again, promise.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h2>My Favorite Things</h2>
<ul class="favorite-things">
<li>Kittens</li>
<li>Rainbows</li>
<li>Unicorns</li>
<li>Sprinkles</li>
</ul>
<script
src="jquery-3.2.1.min.js"></script>
<script src="app.js"></script>
</body>
</html>
$('.favorite-things li').each(function() {
this.prepend('<input type="checkbox">');
});
1 Answer
Steven Parker
231,261 PointsWithin the callback, "this" represent an element, but "prepend" is a jQuery method. So you need to convert "this" into a jQuery object to use "prepend".
Also, the instructions specifically asked you to add "'<input type="checkbox"/>' to the beginning of each list item". Note that it's looking for the XHTML syntax that includes a slash. This wouldn't be necessary in actual practice, so you might want to report it as a bug to the Support folks.
Zachary Eckstein
9,901 PointsZachary Eckstein
9,901 PointsCould you be more specific regarding the, "convert "this" into a jQuery object"?
Steven Parker
231,261 PointsSteven Parker
231,261 Pointsthis $(this)
Zachary Eckstein
9,901 PointsZachary Eckstein
9,901 PointsThank you