【问题标题】:jQuery tab animation pause and play by controllersjQuery选项卡动画由控制器暂停和播放
【发布时间】:2012-04-23 11:02:46
【问题描述】:

我使用 jQuery 选项卡进行轮播,但我需要控制按钮,例如播放和暂停。以下是我的控件。

<p id="carusalSwitch">Autoplay 
  <span class="on">On</span> | <span class="off">Off</span>
</p>

然后页面加载,tab动画暂停(stop),通过按键交互,可以播放,反之亦然。以下是查询代码,

// 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”链接时,动画开始,但当点击“off”时,动画仍然继续。 可能是什么错误?

即使我尝试添加以下代码,

$('#featured > ul').tabs().clearQueue().stop();

但没有运气。

【问题讨论】:

    标签: javascript jquery css animation tabs


    【解决方案1】:

    试试这个:

    $('#featured > ul').unbind('toggle').unbind('rotate');
    

    【讨论】:

    • $('#carusalSwitch .off').click(function() { $('#featured > ul').tabs(); 你想让我替换上面的行吗?我做了但是没有变化。
    【解决方案2】:
    $('#featured > ul').tabs('rotate', null, true);
    

    当我像上面那样使用时,它工作正常。

    【讨论】:

      猜你喜欢
      • 2019-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多