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 3

Christopher Lebbano
Christopher Lebbano
15,338 Points

My #newColor span's background color does not update dynamically like it does it the video.

Instead, it only updates after my mouse-click is released. I am assuming that this line of code here is what's supposed to make this work correctly..

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]").change(changeColor);

Is it just my browser or computer? Or have I done this wrong?

2 Answers

Hi Christopher,

You might have missed the correction in the Teacher's Notes on the previous video: https://teamtreehouse.com/library/jquery-basics/creating-a-simple-drawing-application/perform-part-2

The change event only goes off when you've released the mouse button on the slider so it's not the right event if you want a real time update of the color. The input event goes off whenever the value of an input changes.

Christopher Lebbano
Christopher Lebbano
15,338 Points

Yup I sure did miss the notes, thank you.