我知道这里有一些类似的问题,但我试图获得特定的值。jQuery - 为某个类丢失某个类的元素定义变量和运行函数
我正在研究Flexslider http://www.woothemes.com/FlexSlider/,并试图在幻灯片中添加一些失去“flex-active-slide”类的特殊功能。基于文档,我设法在幻灯片动画之前和之后插入我的函数。
// Callback API
start: function(){},
before: function(){
$('li.image').someFunction(); //this is where I need to trigger this event only to the li.image that's losing the flex-active-slide class
},
after: function() {
$('li.flex-active-slide').otherFunction(); //this is where the active class
},
我并不需要运行功能适用于所有其他li.image
元素你看到的例子以上,只为失去柔性有源滑类之一。
我需要得到这个元素并用变量定义它,这样我才能正确运行li.image
的函数,这对于性能优化目的也是有意义的。
我很感激任何帮助。
我知道这与此有关,但我不明白如何在失去活动类后立即调用该特定li。 – thednp 2012-08-08 04:53:59
在这个活动函数中,'slider.controlNav'指的是其他地方的'li'' slider.currentSlide'指的是'li'。你可以写'var myLi = slider.currentSlide; // remove class code' then'myLi.your code'粗略地说我可以说''myLi''将会成为移除课后'$('li.flex-active-slide')'的快捷方式 – Imdad 2012-08-08 04:57:17
$('li.image') .eq(slider.currentSlide)这是如何获得该幻灯片,非常感谢。你的回答是最好的。我编辑了你的答案,以方便代码搜索者:) – thednp 2012-08-08 05:40:30