Display result for each

The code I provided should work.
The fact that it doesn’t is more likely due to the way your HTML is structured.

What speaks against letting me see the page?


I had a look at the page and got to the bottom of it.

The problem was threefold.

  • You were including the same snippet seven times. You only need to include it once.
  • You had two closing </body> tags and two closing </html> tags
  • You need to include the script at the bottom of your page (preferably just before the closing </body> tag. Or wrap it in a $(document).ready() callback. The reason that nothing was showing for the final image is that you had included the script before it was rendered on the page (thus you couldn’t access it in the DOM).

I PM’d you a link to a working example.

I hope this helps.

Thanks, it worked :smiley:

No probs.

You can also extract the caption like this:

var caption = $("img").attr('src').match(/(\\w+)\\.\\w+[^/]*$/)[1];

This will match the file name, irrespective of the file ending.