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 trialJames Peach
8,019 PointsI'm appending the element correctly and placing it in the variable yet it's always returning wrong. Why?
I've been trying to append this element for a while and it shows up in the preview but it continues to return as wrong. Why is that?
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<h2>Student List</h2>
<ul class="student-list">
<li>James McAvoy</li>
<li>Alena Holligan</li>
<li>Wade Christensen</li>
<li>Matt Krzyzynski</li>
</ul>
<script
src="jquery-3.2.1.min.js"></script>
<script src="app.js"></script>
</body>
</html>
var $newStudent = $('.student-list').append("<li>Sam Smith</li>");
2 Answers
Stuart Wright
41,120 PointsYou should not edit the line which you used to pass task 1. Instead create a second line which appends the element you created in task 1.
Richard Hogge
26,808 PointsI believe Stuart is correct. Your code works, but splitting it onto two lines just makes it more readable:
Line 1 - Store the list item into your variable.
Line 2 - Append this variable to the unordered list.
Give that a shot.
If you're still stuck, I created a CodePen with my solve: https://codepen.io/tremolocreative/pen/ZreKao
James Peach
8,019 PointsThank you so much. That was the fix!
James Peach
8,019 PointsJames Peach
8,019 PointsI tried that. It didn't work. Sorry.