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 trialSyed Abdul Hafiz Bin Syed Hussain
1,559 PointsCant get the color span to update and show change when slider is clicked
Ive looked over my code a few times and can't figure out whats wrong with it.
//Problem: No user interactivity //Solution: Add user interactivity
var color = $(".selected").css("background-color");
//When clicking on control list items $(".controls li").click(function () { //Deselect sibling element $(this).siblings().removeClass("selected"); //Select clicked element $(this).addClass("selected") //cache current color color = $(this).css("background-color");
});
//When new color is pressed $("#revealColorSelect").click(function() { //Show color select or hide the color select changeColor(); $("#colorSelect").toggle(); });
//Update the new color span function changeColor() { var r = $("#red").val(); var g = $("#green").val(); var b = $("#blue").val(); $("newColor").css("background-color", "rgb(" + r + "," + g + "," + b + ")"); }
//When color sliders change $("input[type=range]").change(changeColor);
1 Answer
Joel Bardsley
31,249 Points $("newColor").css("background-color", "rgb(" + r + "," + g + "," + b + ")");
'newColor' isn't a valid selector, you should modify this for whether it's an id or a class.