Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
bxSlider-onslide-before-newieq_Bxslider - Fatal编程技术网

bxSlider-onslide-before-newieq

bxSlider-onslide-before-newieq,bxslider,Bxslider,我试图使用bxSlider在一个响应滑块中调整三个旋转木马(以模拟此站点)中中心幻灯片的不透明度,但无法获得正确的语法 当我使用$slideElement.addClass('active-slide');这种效果发生在错误的幻灯片上,因此,虽然我的基本想法可行,但我需要使用oldIndex和NewIndex而不是$slideElement来引用幻灯片 我尝试了各种排列:- $slider.children.eq(oldIndex).removeClass('active-slide'); $s

我试图使用bxSlider在一个响应滑块中调整三个旋转木马(以模拟此站点)中中心幻灯片的不透明度,但无法获得正确的语法

当我使用$slideElement.addClass('active-slide');这种效果发生在错误的幻灯片上,因此,虽然我的基本想法可行,但我需要使用oldIndex和NewIndex而不是$slideElement来引用幻灯片

我尝试了各种排列:-

$slider.children.eq(oldIndex).removeClass('active-slide');
$slider.$children.eq(oldIndex).removeClass('active-slide');
$('.slider2').children.eq(newIndex).addClass('active-slide');
它们都会阻塞工作,所以我的JS语法显然不正确。谁能可怜我

完整的工作代码是

$(document).ready(function(){
  $('.slider2').bxSlider({
    slideWidth: 300,
    minSlides: 3,
    maxSlides: 3,
    moveSlides: 1,
    slideMargin: 0,
    pager: false,
    auto: true,
    onSlideBefore: function($slideElement, oldIndex, newIndex){
    $slideElement.addClass('active-slide');
            },
    onSlideAfter: function($slideElement, oldIndex, newIndex){
    $slideElement.removeClass('active-slide');
            }
  });

假设您的HTML如下所示:

<div id="container">
    <div class="slide">Slide 1</div>
    <div class="slide">Slide 2</div>
    <div class="slide">Slide 3</div>
</div>
onSlideBefore: function($slideElement, oldIndex, newIndex) {
    $('#container>div').eq(newIndex).addClass('active-slide'));
}