Access to thumbnails through a loop.

I am building a photo gallery and am currently stuck at recognizing which miniature links pic.I'm referring to using the addEventListener function, kindly suggest the method to be executed.

0


a source to share


1 answer


Not really sure what you mean here, but let me make a suggestion:

If your thumbnails link directly to their larger counterpart, you can prevent them from moving away from the page and instead enlarge the animated image to a larger size:

<ul class="thumbnails">
  <li><a href="bigImg1.jpg"><img src="bigimg1_thumb.jpg" /></a></li>
  <li><a href="bigImg2.jpg"><img src="bigimg2_thumb.jpg" /></a></li>
</ul>

      



With this markup, we can have the following jQuery:

$(".thumbnails a").click(function(e){
  e.preventDefault(); /* keeps us from actually leaving the page */
  alert($(this).attr("href")); /* tells us the path to our img */
});

      

Instead of having an alert, you could push a large image over the top of the rest of the page, modally.

0


a source







All Articles