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 trialGreg Knudsen
11,514 PointsColors not updating dynamically
It's not a huge deal, and my code is working. However, in my browser (Chrome Version 43.0.2357.124 (64-bit)), the colors do not change dynamically like they do for Andrew. When I toggle the sliders, the colors only change when I release the click (which makes me want to look down this path as a possible solution). Thanks in advance!
Austin Tindle
8,821 PointsSame here on chrome.
5 Answers
leong shing chew
5,618 Pointsone thing you could do is add a separate event.
mousemove event should work here.
$('input[type=range]').change(changeColor).mousemove(changeColor);
fabio vella
3,548 PointsWell, in this case you don't really need
.change()
VISHAL DEEPAK
3,272 PointsHad the same problem just use the code
//Change this
$("input[type=range]").change(changeColor);
//to this
$("input[type=range]").on("input",changeColor);
Suneal P
4,907 PointsThanks for sharing! This worked for me. Cool.
Minor note, there's a small typo in your code, should be changeColor in the final line.
Regardless, thanks for posting a fix Vishal!
Shane P
11,047 PointsI had the same issue. The best fix I have found is:
$("input[type=range]").on("input",changeColor);
This code will dynamically update the color while dragging the slider, as well as clicking a random spot within the slider.
If you use:
$('input[type=range]').mousemove(changeColor);
the color slider will only update after moving the mouse. Try using this method and clicking a random spot within the slider instead of dragging it, if you leave your mouse still after clicking the color will not update.
stevenstabile
9,763 PointsI had the same issue and this worked like a charm, thanks! but...why did the teacher's example change dynamically??
$("input[type=range]").on("input", changeColor);
Josh Naylor
19,341 PointsGood question! Any ideas?
Jim Withington
12,025 PointsWondering the same over here!
Jay G
2,904 PointsI had the same problem. I decided to not look here first and see if I could figure it out by using jQuery api docs, and was able to use the following:
$('input[type=range]').on('mousemove', changeColor);
Ryan Holdeman
8,067 PointsRyan Holdeman
8,067 PointsI'm having the same problem on my end with Firefox.