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 trialAlexey Tseitlin
5,866 PointsI dont know why but "#newColor" dosent change...
var color = $(".selected").css("background-color");
//When clicking on control list items
$(".controls li").click(function(){
//Deselect sibling elements
$(this).siblings().removeClass("selected");
//Select clicked element
$(this).addClass("selected");
color = $(this).css("background-color");
console.log(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();
$("#newΠ‘olor").css("background-color", "rgb(" + r + "," + g + "," + b + ")" );
}
$("input[type=range]").change(changeColor);
1 Answer
Marcus Parsons
15,719 PointsHey Alexey Tseitlin,
Everything in your code looks like it should work. The change
method doesn't update as you slide. It only updates whenever a mouseup event triggers on the slider. Try changing the change
method to an input method like so:
$("input[type=range]").on("input", changeColor);
Now you should be able to see the color change dynamically as you slide. If there are any more problems, try going into your Web Console and seeing what error pops up.
Alexey Tseitlin
5,866 PointsAlexey Tseitlin
5,866 PointsTried it. Not working(
Alexey Tseitlin
5,866 PointsAlexey Tseitlin
5,866 PointsAlso tried
Doesnt work at all.
Alexey Tseitlin
5,866 PointsAlexey Tseitlin
5,866 Pointsfound it)) thanx
Marcus Parsons
15,719 PointsMarcus Parsons
15,719 PointsI'm glad you found your problem! :)
Josiah Schaefer
7,489 PointsJosiah Schaefer
7,489 PointsThis did it for me! Thank you :)