Question

I'm trying to get the source of the current image in an installation of Cycle2 to pass to an addThis photo sharing script

here is what I have been able to figure out from the Cycle2 API:

$('.cycle-slideshow').on('cycle-after', function (e, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) {
    var imgSrc = $(outgoingSlideEl).attr('src');
});

If I'm missing anything, please advise.

Was it helpful?

Solution

I think your outgoingSlideEl is an list element like li

Then you should use find() to find your image src like,

var imgSrc = $(outgoingSlideEl).find('img').attr('src');

Full Code

$('.cycle-slideshow').on('cycle-after', function(e, optionHash, outgoingSlideEl,
                                                  incomingSlideEl, forwardFlag) {
    var imgSrc = $(outgoingSlideEl).find('img').attr('src');
});

Live Demo

OTHER TIPS

can you give a try to below code..i hope it works

var imgSrc = $(outgoingSlideEl).find('img').attr('src');

Demo :-

http://jsfiddle.net/3vjgJ/42/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top