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 trialSumama Waheed
1,819 PointsNot 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
32,867 PointsHi 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
1,819 PointsI 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
32,867 PointsI'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.
Sumama Waheed
1,819 PointsSumama Waheed
1,819 PointsHow 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
32,867 PointsSeth Reece
32,867 PointsFor the syntax error, I think you want: