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 Interactive Web Pages with JavaScript Traversing and Manipulating the DOM with JavaScript Changing Classes

On line 5 of app.js, use the classList property on the anchor to add a new class of "selected" to it.

What is the answer of it ?

Let's see the code you have tried.

10 Answers

Sreng Hong
Sreng Hong
15,083 Points

Hi Sura

Here is the answer:

anchor.classList.add("selected");
chaz
chaz
25,372 Points
.add()

this isn't covered at any point during the lesson. The lack of continuity between the lesson project and code challenge projects is Treehouse's greatest weakness.

Thnk you mate. It works fine for me. I just wanted to save myself from javascript. I understood nothing from Andrew and Jim. I will continue on PHP and CSS.

Sura,

Make sure that you're trying to figure these out on your own, google everything that you're having trouble with and you will learn much faster.

That being said, anchor.classList.toggle('live'); will get the job done.

Luke

Harry Beckwith
Harry Beckwith
13,452 Points

For jQuery and basic javascript projects i would recommend https://www.udemy.com/projects-in-javascript-jquery/ really valuable lessons learnt!

THNk you. On about line 9 in app.js, use classList to toggle the "live" class on the anchor element. ?

Sreng Hong
Sreng Hong
15,083 Points

I think it's simply the same. All you have to do is read the instruction clearly.

They said use classList to toggle the live class on the anchor element, so you can use the same answer from task 1 of 2 to change the keyword add to toggle and the class selected to live.

Hope this helps.

I did it mod's can clear my posts.Thats all and im done.

Tony Brackins
Tony Brackins
28,766 Points

Hey Sura,

These classes from Jim and Andrew were EXTREMELY difficult. With that said, don't give up! You will get a little piece from each class and can do learning in other places as well.

Here's a good course that I found in the forums that explains a little better: https://www.youtube.com/watch?v=LsY2PsPKckU&feature=youtu.be

sure,, thanks guys, at least i know its not me alone,,i didnt get anything from Andrew,,his approach is something,, will try understand from other sources.

Harry Beckwith
Harry Beckwith
13,452 Points

The lessons are very technical and specific to that certain problem. But to be honest i would not know how to apply it to another problem, just from these videos. Saying that i have learnt a few things. I am thinking of buying a text book to try and understand javascript applied on websites.... any one know of a good one?

David Hughes
David Hughes
5,063 Points

I have to agree with some comments from others. I have some understanding of JavaScript before starting this course. And though the course DOES introduce us to several new ways of performing tasks, they aren't really explained. I spent a lot of time reviewing my own code and entering really long comments to better explain what was not being explained in the videos.

In a way this was an effective way to learn. But there were many times that I was entirely lost. I think the course just needed some additional clarity. It is was really difficult to follow how

addButton.onclick = addTask;

triggered addTask, which would then createNewTaskElement, and pass in a variable that we defined globally at the start of the lesson.

As I said, I did learn from this, but I feel that I could have learned even more had each step been explained a bit more clearly.

With all of that being said(I think I'm the third person to use that phrase on this thread) TreeHouse courses have been amazing thus far.

Herman Morales
Herman Morales
8,831 Points

this is the answer anchor.classList.toggle('live');