0

这里http://jsfiddle.net/comparebest/yBcKk/6/我有一个 jQuery 滑块和两个 Div - DIV ONE 和 DIV TWO。

有没有办法让我自动拥有它:

1)当滑块显示幻灯片 1 时,替换 DIV ONE 的类(从“test”到“testc”)。

2)当滑块显示幻灯片 2 时,替换 DIV TWO 的类(从“test1”到“test1c”)。

4

1 回答 1

4

我想出了一个使用你的索引的解决方案,.paging a.active看看这个小提琴 这是我在你的旋转函数中添加的:

 if ($('.paging a.active').index() == 0){
                //alert('slide1');  
            $('.test').removeClass('test').addClass('testc').html('DIV ONE now has class: testc');          
            }
        if ($('.paging a.active').index() == 1){
                //alert('slide1');  
            $('.test1').removeClass('test1').addClass('test1c').html('DIV TWO now has class: test1c');          
            }

基本上,如果 .paging a.active index = 0 (真的滑动一个)然后相应地更改 div 。它只是不适用于滑块的初始加载,因为直到它移动到第二个滑块才会调用旋转函数。

于 2012-10-12T18:14:38.050 回答