我已经使用jQuery选项卡进行轮播,但我需要像播放和暂停这样的控制按钮。以下是我的控件。
<p id="carusalSwitch">Autoplay
<span class="on">On</span> | <span class="off">Off</span>
</p>
然后页面倾斜,选项卡动画暂停(停止),通过按钮交互,可以播放,反之亦然。 下面是查询代码,
// when loaded carousal is paused, off text is change to bold
$('#carusalSwitch .off').css('fontWeight','bold');
// when user click on "ON" link
$('#carusalSwitch .on').click(function() {
$('#featured > ul').tabs({fx:{opacity: 'toggle'}}).tabs('rotate', 3000, true);
$(this).css('fontWeight','bold');
$('#carusalSwitch .off').css('fontWeight','normal');
});
// when user click on "OFF" link
$('#carusalSwitch .off').click(function() {
$('#featured > ul').tabs();
$(this).css('fontWeight','bold');
$('#carusalSwitch .on').css('fontWeight','normal');
});
当您单击"ON"链接时,动画开始,但当单击"关闭"时,动画仍会继续。可能有什么错误?
即使我尝试添加以下代码,
$('#featured > ul').tabs().clearQueue().stop();
但没有运气。
试试这个:
$('#featured > ul').unbind('toggle').unbind('rotate');
$('#featured > ul').tabs('rotate', null, true);
当我如上所述使用时,它工作正常。