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 trial

JavaScript jQuery Basics (2014) Creating a Simple Drawing Application Perform: Part 2

I 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

Hey 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.

Tried it. Not working(

Also tried

$("#addNewColor").click(function() {
  changeColor;
});

Doesnt work at all.

found it)) thanx

I'm glad you found your problem! :)

Josiah Schaefer
Josiah Schaefer
7,489 Points

This did it for me! Thank you :)