我正在使用jQuery循环插件,并且在添加播放/暂停选项后遇到了一些麻烦。jQuery循环插件问题
代码如下所示;
$('#img').cycle({
fx: 'fade',
speed: 'slow',
timeout: 1000,
pager: '.imagegallerypager.r2s1',
pagerClick: function (zeroBasedSlideIndex, slideElement) {
$('#txt').cycle({
startingSlide: zeroBasedSlideIndex
});
$('#txt').cycle('pause');
$('#img').cycle('pause');
}
});
$('#txt').cycle({
fx: 'none',
speed: 'slow',
timeout: 1000
});
$('#playpause, .imagegallerypager a').click(function() {
if ($('#playpause').attr('class') == 'pause') {
$('#txt').cycle('pause');
$('#img').cycle('pause');
$('#playpause').html('<img src="images/icon_play.gif" alt="Play" title="Play" />');
$('#playpause').removeClass('pause');
$('#playpause').addClass('play');
}
else if ($(this).attr('class') == 'play') {
$('#txt').cycle('resume');
$('#img').cycle('resume');
$('#playpause').html('<img src="images/icon_pause.gif" alt="Pause" title="Pause" />');
$('#playpause').removeClass('play');
$('#playpause').addClass('pause');
}
});
该脚本运行良好,直到我按下暂停按钮,然后播放按钮再次开始动作。 img运行良好,但txt似乎有设置重置(即fx effet,超时效果等)导致img和txt被设置,不再遵循对方。我尝试了很多不同的东西,但迄今没有运气。
有什么建议吗?
无关,但检查'.attr( '类')== ...'是不是检查好'.hasClass(...)' 。不要忘记标签可能有多个类,并且'=='比较不会总是有效。 – VoteyDisciple 2010-10-11 14:32:07