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

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

Alex Lowe
Alex Lowe
15,147 Points

Uncaught TypeError: undefined is not a function

I get that error in the console when I click on the Add Color Button. The error is on line 42 in my #addNewColor click event handler. I've looked it over a bunch of times and I looked at the other discussion question and I still can't see what I've don't wrong.

//PROB: no user interaction, no change to application
//SOL: when user interacts, cause appropriate changes
var color = $(".selected").css("background-color");

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


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


//when add color is pressed
  //append the color to control list items
  //select new color
$("#addNewColor").click(function(){
  var $newColor = ("<li></li>");
  $newColor.css("background-color", $("#newColor").css("background-color"));
  $(".controls ul").append($newColor);
  $newColor.click();
});
Alex Lowe
Alex Lowe
15,147 Points

I left out a $ in: var $newColor = ("<li></li>");