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 One Solution

Why was it not appropriate to use .html when appending the span tags?

.

Kristaps Vecvagars
Kristaps Vecvagars
6,193 Points

I'm not sure, if it is so, but I treat .html() method almost the same as I would treat .innerHTML in vanilla JS.

For example, this was my solution for task 4/5:

$('a').each(function(index){
  console.log(index, $(this).html());
});

I used .html() to get the innerHTML content of the <a> tags, while Treasure used .text().

1 Answer

Steven Parker
Steven Parker
229,785 Points

The code being appended in this exercise is HTML code. It's just being added to the page by the JavaScript program.

Steven Parker
Steven Parker
229,785 Points

Amandeep Pasricha — Did this resolve your issue? You can mark a question solved by choosing a "best answer".
And happy coding!