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 jQuery Basics (2014) Creating a Simple Drawing Application Perform: Part 1

Sumama Waheed
Sumama Waheed
1,819 Points

Not selecting other colors? Where did this "selected" come from? I would appreciate a brief explanation on its usage.

var color = ("selected").css.("background-color"); $(".controls li").click(function(){ $(this).siblings().removeClass("selected"); $(this).addClass("selected"); color = $(this).css.("background-color"); });

Uncaught SyntaxError: Unexpected token "("

2 Answers

Seth Reece
Seth Reece
32,867 Points

Hi Sumama,

It looks like this script is assigning a class of selected to a link when it is clicked, and making sure that none of the sibling links have the class of selected. This will dynamically alter a menu of links so that the current page your on has a different color for that page's link. Selected is just a popular class name for this type of interactivity.

Sumama Waheed
Sumama Waheed
1,819 Points

How do you think I should correct it ?I am not sure in the index.html file I just have "red selected" and others are not.

Seth Reece
Seth Reece
32,867 Points

For the syntax error, I think you want:

var color = $("selected").css.("background-color");
// Instead of:
var color = ("selected").css.("background-color");
Sumama Waheed
Sumama Waheed
1,819 Points

I have tried var color = $("selected").css.("background-color"); and var color = $(".selected").css.("background-color");

I still am not able to select other colors.

Seth Reece
Seth Reece
32,867 Points

I'm not sure what you're asking then. Your index.html file won't change. If you click on a color and then "Inspect element" in your browser, that color's li will have the class of selected.