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
Kun Qian
14,870 PointsWorkspace not working properly
Sometimes my Workspace is not working properly. especially for the recognition of Javascript ( and jQuery). When I type in exactly the same commend as inputted by the video, the preview doesn't work properly. it always seems that the browser doesn't really call the command.
There's also a detail I noticed that might cause the error. For example when I type in $("test"), the string test is supposed to turn into blue as suggested by the video but it stays green in my window. I'm not exactly sure what caused this, and I'm using a chrome browser as well.
Thanks very much Treehouse! Kun
var $overlay = $('<div id = "overlay"></div>');
var $image = $("<img>");
var $caption = $("<p></p>");
$overlay.append($image);
$overlay.append($caption);
$("body").append($overlay);
$("#imageGallery a").click(function(event){
event.preventDefault();
var imageLocation = $(this).attr("href");
$image.attr("src", imageLocation);
$overlay.show();
});
$overlay.click(function(){
$overlay.hide();
})
Kun Qian
14,870 PointsJust did
1 Answer
Kun Qian
14,870 PointsI think my code is identical to the video script, also I tried it on another text editor (atom) and it performs well. therefore I'm wondering.
var $overlay = $('<div id = "overlay"></div>');
var $image = $("<img>");
var $caption = $("<p></p>");
$overlay.append($image);
$overlay.append($caption);
$("body").append($overlay);
$("#imageGallery a").click(function(event){
event.preventDefault();
var imageLocation = $(this).attr("href");
$image.attr("src", imageLocation);
$overlay.show();
});
$overlay.click(function(){
$overlay.hide();
})
Michael Afanasiev
Courses Plus Student 15,597 PointsMichael Afanasiev
Courses Plus Student 15,597 PointsHi Kun,
Can you post your code so we can inspect?