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

Franklin Colbert
Franklin Colbert
4,868 Points

#newColor span doesn't show up at all

I can't get the #newColor box to show up at all

// problem: no user interaction causes changes to the application
// solution: when user interacts, appropriate changes occur

var color = $('.selected').css("background-color");

// when clicking on control list items (color selectors)
$(".controls li").click(function(){                       
// deselect siblings
  $(this).siblings().removeClass("selected");
  // select color we just clicked
  $(this).addClass("selected");
  //cache current color
  $(this).css("background-color");
                        });

// when new color is pressed
$("#revealColorSelect").click(function(){
  // show color select or hide 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]").on("input", schangeColor);

// when add color is pressed
 // append color to the controls ul
 // select the new color


// on mouse events on the canvas
  // draw lines

1 Answer

LaVaughn Haynes
LaVaughn Haynes
12,397 Points

you had some typos. javaScript is case sensitive

// update the new color span
function changeColor() {
  var r = $("#red").val();
  var g = $("#green").val();
  var b = $("#blue").val();

  //wrong case: newcolor should be newColor ******************
  //$("#newcolor").css("background-color", "rgb(" + r + "," + g + "," + b + ")");
  $("#newColor").css("background-color", "rgb(" + r + "," + g + "," + b + ")");
};
// when color sliders change
//bad code: also schangeColor is not a function ******************
//$("input[type=range]").on("input", schangeColor);
$("input[type=range]").on("change", changeColor);
Franklin Colbert
Franklin Colbert
4,868 Points

thanks, I keep forgettin that lowerCamelcase !