Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Sonja Tomcic
Sonja Tomcic
6,590 Points

The new color circle doesn't apear

when i click on add color, there is no new circle, just empty space and under it it says $newColor

//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").on("click", "li", function(){
  //deselect sibling elements
  //select clicked element
  //cache current color

//when new color is pressed
  //show color select or hide the color select

//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

//when add color is pressed
  //append the color to the controls ul
  var $newColor = $("<li></li>");
  $newColor.css("background-color", $("#newColor").css("background-color"));
  $(".controls ul").append("$newColor");

  //select the new color

//on mouse events on the canvas
  //draw lines
18,266 Points

You can do 3 ( ` ) followed by js for a js code block.

1 Answer

18,266 Points
// This is causing the issue, you are adding a string instead of the variable.
$(".controls ul").append("$newColor");

// This will add new color
$(".controls ul").append($newColor);

Since you saved $newColor as a variable it needs to be used as a variable or else you will see $newColor as a string.

Sonja Tomcic
Sonja Tomcic
6,590 Points

thank you, I haven't seen that