我正在使用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