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 4

code not working

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


$('.controls').on('click', 'li', function(){
  $(this).siblings().removeClass('selected');
  $(this).addClass('selected');
  color = $(this).css('background-color'); //updates currently selected color
});


$('#revealColorSelect').on('click', function() {
  changeColor();
  $('#colorSelect').toggle();
});


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]').on('input', changeColor);


$('#addNewColor').on('click', function() {
  var $color = $('</li></li>');
  $color.css('background-color', $('#newColor').css('background-color'));
  $('.controls ul').append($color);

  $color.click();
});

when i click #addNewColor, the <li> does not show up in the html. it is not appending my <li> for some reason. i checked using developer tools. help pls. thanks

1 Answer

Hi sibal,

One thing I noticed is that you have 2 closing li tags here instead of an opening and closing tag.

var $color = $('</li></li>');

Post back if it's still not working and I can take a closer look.

thank u jason. i never noticed that

it works now