jQuery Accordion with auto next

时间:2013-01-30 16:46:28

标签: jquery accordion

我有一支手风琴可以点击很好,但我需要它才能在3秒后进入下一张幻灯片。我已经搜索并找到了一个想法here,但似乎无法使其与它的实际点击对应物一起发挥作用。任何想法都非常感谢!

/* Part 1 -> Set first to active */
jQuery("#accordionBackground .theSlide:first").addClass('active');
/* Part 2 -> Auto change */
$theNextSlide = jQuery(this).next('.theSlide');
    if($theNextSlide.length==0){$theNextSlide=jQuery('.theSlide:first');}
     $next.find('.theSlide').triggerHandler('click');
},3000);
/* Part 3 -> Manual change */
jQuery("#accordionBackground .theSlide").click(function(){
    jQuery("#accordionBackground .theSlide").not(this).animate({width: "35px"}, {duration:'fast', queue:false});
    jQuery("#accordionBackground .theSlide").not(this).removeClass('active');
    jQuery(this).addClass('active');

    jQuery(this).next('.theSlide').addClass('nextSlide');
    jQuery(this).animate({width: "588px"}, {duration:'fast', queue:false});


});

谢谢,Dan

修改

进一步尝试,但仍然没有运气! - >

jQuery(document).ready(function(){
    setTimeout('accordionAutoNext()',3000);
});

function autoNext(){
    $theNextSlide = jQuery(this).next();
    if($theNextSlide.length==0){$theNextSlide=jQuery('.theSlide:first');}
     $next.find('.theSlide').triggerHandler('click');
};

1 个答案:

答案 0 :(得分:0)

发现它!

/* Part 1 -> Set first to active */
jQuery("#accordionBackground .theSlide:first").addClass('active');
/* Part 2 -> Manual change */
jQuery("#accordionBackground .theSlide").click(function(){
    jQuery("#accordionBackground .theSlide").not(this).animate({width: "35px"}, {duration:'fast', queue:false});
    jQuery("#accordionBackground .theSlide").not(this).removeClass('active');
    jQuery(this).addClass('active');

    jQuery(this).next('.theSlide').addClass('nextSlide');
    jQuery(this).animate({width: "588px"}, {duration:'fast', queue:false});
});
/* Part 3 -> Auto change */
var nextAccordion = function(){
    $theNextSlide = jQuery('.theSlide.active').next('.theSlide');
    if($theNextSlide.length==0){$theNextSlide=jQuery('.theSlide:first');}
     $theNextSlide.trigger('click');
};
setInterval(nextAccordion,6000);
/*End accordion */