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 trialErin Fincher
4,101 PointsUncaught SyntaxError: Unexpected token }
I'm getting an unexpected token error and I can' t figure out why. My function won't close, the curly braces for whatever reason are not registering. I know I've just probably forgotten a character or something, but can't figure it out
function changeColor() {
var r = $("#red").val();
var g = $("#green").val();
var b = $("#blue").val();
$("#newColor").css("background-color", "rgb(" + r + ", " + g +"," + b + ")"
}
2 Answers
Dino Paškvan
Courses Plus Student 44,108 PointsYou are missing the closing parenthesis )
of the .css()
method and a semi-colon (although the semi-colon isn't mandatory in this case).
Chris Southam
1,823 Points$("#newColor").css("background-color", "rgb(" + r + ", " + g +"," + b + ")");
Needs the final ) and optional ; as Dino says.