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 trialLe Var Range
Front End Web Development Techdegree Student 18,011 Pointscan anybody tell me where I am going wrong with appending the arrows to my interactive photo album
var $arrow1 = $("<img src='icon/arrows.svg' ");
var $arrow2 = $("<img src='icon/arrows-1.svg' ");
var $para = $("<p></p>");
var $image = $("<img>");
var $overlay = $("<div id='overlay'></div>");
// AdDiNg OvErLaY aNd iMaGe WiTh TeXt //
$overlay.append($image);
$overlay.append($arrow1);
$overlay.append($arrow2);
$overlay.append($para);
$("body").append($overlay);
// iMaGe CliCk FuNcTiOn ShOwInG oVeRlAy //
$(".pic-nav li a").click( function(e) {
e.preventDefault();
var imageLoc = $(this).attr("href");
$image.attr("src", imageLoc);
$overlay.show();
var captionTex = $(this).children("img").attr("alt");
$para.text(captionTex);
var left = $(this).attr(imageLoc);
$arrow2.attr("src", imageLoc);
});
$image.click( function() {
$overlay.hide();
});
I am trying to append the arrows that lets u choose the next or previous image .. I am so unsure of how to do this .. even with Jon Duckett's book on Jquery. I would like to have some tips on how I can wrap my brain on how to do this .. I know a bit of what I am doing but just applying is a bit tricky.
1 Answer
Steven Parker
231,198 PointsI didn't try running it, but at first glance, it looks like you forgot to close the img tags in $arrow1 and $arrow2
var $arrow1 = $("<img src='icon/arrows.svg'>"); // note: ">" added
var $arrow2 = $("<img src='icon/arrows-1.svg'>"); // note: ">" added