quote: You show the image that is the immediate sibling of the current one. That's the problem – no assumptions are (currently, at least) made about the structure of the HTML. The script attaches a click handler to the document body and, starting with the event's target, works its way up through the DOM tree until it finds an appropriate link (in which case it shows a popup), or it reaches the top of the tree. It has no knowledge of adjacent nodes, nor at what level it should start traversing back down the tree to find the next link. There needn't even be any images on the page itself, merely links to them.
HTML code:
<ul id="container1">
<li><span>(1 of 3)</span> <a href="kitten.jpg">Kitten</a></li>
<li><span>(2 of 3)</span> <a href="puppy.jpg">Puppy</a></li>
<li><span>(3 of 3)</span> <a href="squirrel.jpg">Squirrel</a></li>
</ul>
|