Add title to jQuery Cycle slideshow from Alt attribute?
I am building a slideshow and need to have a title appear for each picture that get cycled. I created alt attributes for the开发者_开发技巧m and am trying to have cycle display them for each image, but It only shows the first one. I am unsure how to get the code I have into the cycle "loop" for the gallery? Does this make sense? here is what I have, (well, part of it I mean) :) thanks!
$('#slideshow').before('<div class="navigation">').cycle({
fx: 'fade',
timeout: 6000,
pager: '.navigation'
});
$('.image_title').html($(this).find('img').attr('alt'));
Just move that code into the before or after callback. For example:
$('#slideshow').before('<div class="navigation">').cycle({
fx: 'fade',
timeout: 6000,
pager: '.navigation',
after: function() {
var title = $(this).attr('alt');
$('.image_title').html(title);
}
});
精彩评论