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 trialMelissa Kepler
11,369 Pointsperform: Part 1 code vs. the code from the download
I was having trouble getting the code from the first part of the canvas drawing project to work. I downloaded the app.js file so I could check them side by side and saw it was different than the code from the video. I pasted the downloaded code in and it worked with no problem. I am running chrome on a pc (I was having the same issue on my mac), and I refreshed it before I tried any interaction. Why is the code that much different, is it a change that takes place later in the video? Has anyone else had this problem?
Below is the video code vs. the code from the download. It is only the code used for the first part of the project, and the comments between the lines were removed.
//code from the video
var color = $(".selected").css("background-color");
$(".controls li").click(function() {
$(this).siblings().removeClass("selected");
$(this).addClass("selected");
color = $(this).css("background-color");
});
//code from the download
var color = $(".selected").css("background-color");
$(".controls").on("click", "li", function(){
$(this).siblings().removeClass("selected");
$(this).addClass("selected");
color = $(this).css("background-color");
});
Alan Jenkins
10,878 PointsI am running Chrome too. The code I'm using is exactly as shown in the video and it won't work for me either. Is the code in the video wrong or is it because I"m using chrome?
John Renzema
9,070 PointsJohn Renzema
9,070 PointsYou just made one small mistake in your code.
look at the first line after you set the variable.
$(".controls li").click(function() {
vs.
$(".controls").on("click", "li", function(){
".on" is a more dynamic function, and is easier to adjust FYI.
Hope that helps.