我想在一个页面上有几个循环画廊,但一次只有一个活动,而其他的则隐藏。理想情况下,单击链接(列表中的缩略图)将激活下一个循环库。有道理?以前有人做过吗?不胜感激提示,谢谢!
问问题
1642 次
2 回答
3
未经测试,但这样的事情应该很接近:
$(document).ready(function() {
// initialize and hide both slideshows
$('#gallery1,#gallery2').each(function() {
var $nav = $('<ul class="gallery-nav">').insertBefore(this);
$(this).cycle({
fx: 'slideY',
speed: '1000',
timeout: 6000,
pager: $nav,
pagerAnchorBuilder: function(i) {
return '<li><a href="#">'+(i+1)+'</a></li>';
}
}).cycle('pause').hide();
});
// bind click triggers to show/hide galleries
$('.gallery1,.gallery2').click(function() {
var isOne = $(this).is('.gallery1');
var showId = '#gallery' + isOne ? 1 : 2;
var hideId = '#gallery' + isOne ? 2 : 1;
$(hideId).cycle('pause').hide();
$(showId).show().cycle('resume');
return false;
});
});
于 2010-03-22T15:55:19.083 回答
1
好的,既然我已经看到了您的网站,我可以看到您需要更灵活的东西,因为您有大约 15 个画廊要控制。试一试:
$(document).ready(function() {
$.expr[':'].gallery = function(a) { return /^gallery\d+/.test(a.id); }
// initialize and pause the slideshows
var $gallery = $(':gallery').each(function() {
var $nav = $('<ul class="gallery-nav">').insertBefore(this);
$(this).cycle({
fx: 'slideY',
speed: 1000,
timeout: 6000,
pager: $nav
}).cycle('pause');
});
var $navs = $('ul.gallery-nav');
// hide all but first gallery and pager and restart first gallery slideshow
$navs.not(':eq(0)').hide();
$gallery.not(':eq(0)').hide()
$gallery.eq(0).cycle('resume');
// bind click triggers to show/hide galleries
var $thumbs = $('#slider_thumbs a').click(function() {
var index = $thumbs.index(this);
$gallery.not(':eq('+index+')').cycle('pause').hide();
$gallery.eq(index).show().cycle('resume');
$navs.eq(index).show();
$navs.not(':eq('+index+')').hide();
return false;
});
});
于 2010-03-23T00:37:32.030 回答