Background: I am updating an existing photo gallery plugin that displays a large image in the center and gradually reduces the image on both sides.
So my question is this: I set some data on each image that gives the index of the image, the index of the next image and the index of the previous image, for example:
$(this).data('index', i).data('prev', i - 1).data('next', i + 1);
Later, I would like to be able to select an image based on its index. I tried the following but it does not work:
$('[data-index=' + index + ']');
Is there a way to select an item based on the piece of data attached with .data()?
Ender source
share