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 trialPurvi Agrawal
7,960 PointsMy project is not working the way it should. When I click an image it stills go to the next web page.
When I click the image, it still opens in the new web page. Not sure what I am doing wrong.
The code is pasted below.
------- Index.html-------
<!DOCTYPE html>
<html>
<head>
<title>Lightbox</title>
<link rel="stylesheet" type="text/css" href="css/styling.css">
</head>
<body>
<h1 id="heading">Welcome to the Gallery !!</h1>
<p id="description">
Have a Sneak Peak at Mackinac Island, Michigan.
</p>
<div id="gallery">
<a href="images/p1.jpg"><img src="images/p1.jpg" alt="p1" ></a>
<a href="images/p2.jpg"><img src="images/p2.jpg" alt="p2"></a>
<a href="images/p3.jpg"><img src="images/p3.jpg" alt="p3"></a>
<a href="images/p4.jpg"><img src="images/p4.jpg" alt="p4"></a>
<a href="images/p5.jpg"><img src="images/p5.jpg" alt="p5"></a>
<a href="images/p6.jpg"><img src="images/p6.jpg" alt="p6"></a>
<a href="images/p7.jpg"><img src="images/p7.jpg" alt="p7"></a>
<a href="images/p8.jpg"><img src="images/p8.jpg" alt="p8"></a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="js/app.js" type="text/javascript" ></script>
</body>
</html>
------------ app.js------------
$("#galllery a").click(function(event){
event.preventDefault();
var $href = $(this).attr("href");
//console.log(href);
});
2 Answers
Dan Oswalt
23,438 PointsI haven't tested your code, but I do notice that you misspelled gallery
in your javascript file as galllery
. That may the hangup.
Purvi Agrawal
7,960 PointsPerfect.. !! Thank U for noticing this. I wud have gone through the code 10 times but could not locate it. Its working as it should !
Dan Oswalt
23,438 PointsGreat! Sometimes it just needs a second pair of eyes
Rich Donnellan
Treehouse Moderator 27,696 PointsRich Donnellan
Treehouse Moderator 27,696 PointsI fixed your code formatting. Use the Markdown Cheatsheet for proper syntax instructions.