JQuery Gallery+幻灯片
我正在尝试建立一个每 4 秒旋转一次图像的画廊。 除了上述之外,我还需要一个功能,以便如果单击缩略图,则单击的图像会显示在大图像区域中。这就是我正在做的事情:
function InOut( elem )
{
elem.removeClass("hidden")
.fadeIn("slow")
.delay(2000)
.fadeOut("slow", function(){
if(elem.next().length > 0)
InOut( elem.next() );
else
InOut( elem.siblings(':first'));
});
}
$("a.thumbnail").click(function(){
var MainImgID = $(this).attr("rel");
$("#BigImage img").hide();
InOut($("#BigImage img:nth-child("+MainImgID+")"));
});
这是快速的 HTML
<div id="BigImage">
<img src="images/1.jpg" id="0" class="hidden" />
<img src="images/12.jpg" id="1" class="hidden" />
<img src="images/10.jpg" id="2" class="hidden" />
</div>
<div id="thumb">
<ul>
<li><a rel="0"><img src="images/thumbs/1.jpg" /></a></li>
<li><a rel="1"><img src="images/thumbs/12.jpg" /></a></li>
<li><a rel="2"><img src="images/thumbs/10.jpg" /></a></li>
</ul>
</div>
问题 问题是,当我单击缩略图时,自动旋转会出现混乱。它会在主图像下方开始另一个幻灯片放映。如果我再次单击,它会在下面开始另一个(第三张)幻灯片,依此类推......
请帮助......
谢谢
I am trying to build a gallery that rotate its images after every 4 seconds.
In addition to above, I need a function so that if a thumbnail image is clicked, that clicked image show up in the Big Image Area. Here is what I am doing:
function InOut( elem )
{
elem.removeClass("hidden")
.fadeIn("slow")
.delay(2000)
.fadeOut("slow", function(){
if(elem.next().length > 0)
InOut( elem.next() );
else
InOut( elem.siblings(':first'));
});
}
$("a.thumbnail").click(function(){
var MainImgID = $(this).attr("rel");
$("#BigImage img").hide();
InOut($("#BigImage img:nth-child("+MainImgID+")"));
});
And Here is quick HTML
<div id="BigImage">
<img src="images/1.jpg" id="0" class="hidden" />
<img src="images/12.jpg" id="1" class="hidden" />
<img src="images/10.jpg" id="2" class="hidden" />
</div>
<div id="thumb">
<ul>
<li><a rel="0"><img src="images/thumbs/1.jpg" /></a></li>
<li><a rel="1"><img src="images/thumbs/12.jpg" /></a></li>
<li><a rel="2"><img src="images/thumbs/10.jpg" /></a></li>
</ul>
</div>
PROBLEM
The problem is that auto-rotation messed up when I click the thumbnail image. It starts another slideshow right below the main image. If I click again, it start another (third) slideshow below and so on....
Please help...
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你不应该在回调中运行
InOut
,只需让其他图像隐藏,然后大图像显示如下:(假设它们有按顺序排列的 id)I think you should not run
InOut
in the callback, just make the other images hide, and the big image show like this: (assuming they have id that is in order)