Frage

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.

War es hilfreich?

Lösung

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

Andere Tipps

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/

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top