jsor / jcarousel

Riding carousels with jQuery.
https://sorgalla.com/jcarousel/
MIT License
1.99k stars 734 forks source link

Adding text on image #728

Closed BELAGE closed 9 years ago

BELAGE commented 9 years ago

hello,

I would like to add a small text above each image on the stage.

Is it possible ?

not a fix text like photo-credits, but text coming from database linked on each image.

(I'm using a foreach for displaying image and everything is ok, I just need to add the title of each image).

Thank you for your advice and nice work !

Zino

jsor commented 9 years ago

You could use the targetin event to change the captions stored in a data-attribute:

var caption = $('.caption');
$('.jcarousel').on('jcarousel:targetin', 'li', function(event, carousel) {
    caption.html($(this).data('caption'));
});

An item should look like this:

<li data-caption="My caption"><img src=""></li>
BELAGE commented 9 years ago

Thank you

Envoyé de mon iPhone

Le 19 nov. 2014 à 11:53, Jan Sorgalla notifications@github.com a écrit :

You could use the targetin event to change the captions stored in a data-attribute:

var caption = $('.caption'); $('.jcarousel').on('jcarousel:targetin', 'li', function(event, carousel) { caption.html($(this).data('caption')); }); An item should look like this:

  • — Reply to this email directly or view it on GitHub.