简体   繁体   English

在cycle2滑块中获取当前幻灯片的图像源

[英]get image source of current slide in cycle2 slider

I'm trying to get the source of the current image in an installation of Cycle2 to pass to an addThis photo sharing script 我正在尝试在Cycle2的安装中获取当前图像的源,以传递给addThis照片共享脚本

here is what I have been able to figure out from the Cycle2 API: 这是我从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. 如果我缺少任何东西,请告知。

I think your outgoingSlideEl is an list element like li 我认为您的outgoingSlideEl是像li这样的list element

Then you should use find() to find your image src like, 然后,您应该使用find()查找image src例如

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 现场演示

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/ http://jsfiddle.net/3vjgJ/42/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM