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 trialYijiao Wang
1,793 PointsActual color doesn't show on but only rgb values e.g. rgb(179,0,0)
$('#addNewColor').click(function(){ var $newColor=$('#newColor').css('background-color'); $('.controls ul').append('<li>'+$newColor+'</li>'); });
That's the last part of my code and I don't know what's wrong with it. Also when I try to use $newColor.css() statement like the video did, it gives me error message that $newColor is not define or $newColor.css is not a function.
1 Answer
Bernadette Guevarra
16,295 PointsSince you used var $newColor=$('#newColor').css('background-color'); basically the variable returns an rgb value of the span element with an id of newColor. I think the code goes like this
$("#addNewColor").click(function() {
var $newColor = $("<li></li>").css("background-color", $("#newColor").css("background-color"));
$(".controls ul").append($newColor);
$newColor.click();
});