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 trialDEGUI Adil
2,449 PointsWhen I refresh the page then click on "New Color" it doesn't show the actual RGB values. I have to move the slider
When Andrew refresh the page and click on the "New Color" button, it shows a black square (the actual sliders value 0 0 0), but when I do click on the button, it only shows a white square, I have to move on of the sliders so the color can show.
//Problem: No user interaction causes no change to application
//Solution: When user interacts cause changes appropriately
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");
//cache current color
color = $(this).css("background-color");
});
//When new color is pressed
$("#revealColorSelect").click(function(){
//Show color select or hide the color select
$("#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 + ")");
}
$("input[type=range]").change(changeColor);
//When add color is pressed
//Append the color to the controls ul
//Select the new color
//On mouse events on the canvas
//Draw lines
2 Answers
Jason Anello
Courses Plus Student 94,610 PointsIt looks like you're missing a call to changeColor inside your click handler for the "New color" button.
//When new color is pressed
$("#revealColorSelect").click(function() {
//Show color select or hide the color select
changeColor();
$("#colorSelect").toggle();
});
DEGUI Adil
2,449 PointsThank you!