页面加载时隐藏jCarousel [英] Hide a jCarousel when page loads

查看:93
本文介绍了页面加载时隐藏jCarousel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做类似的事情:

jQuery('#ImgCarousel').jcarousel({});
jQuery('#ImgCarouselCon').hide();

ImgCarouselCon是围绕转盘包装的容器div.使用此代码,轮播在隐藏时仍在加载,并且出现错误.我查看了jCarousels文档,但找不到有效的回调.像onComplete这样的东西很理想,但是没有骰子.

ImgCarouselCon is the container div that is wrapped around the carousel. With this code the carousel is still being loaded when it is hidden and I get errors. I looked at jCarousels documentation but I can't find a callback that would work. Something like onComplete would be ideal but no dice.

推荐答案

您可以将容器元素的位置设置为position:absoluteleft:-999em(或足够大的数字),因此对于jcarousel可以进行设置,但在页面上看不到它.

You could set the position of the container element to be position:absolute and left:-999em (or some sufficiently large number), so it's still "displayed" for jcarousel to be able to set it up, but it's not anywhere visible on the page.

然后,当您要显示它时,只需将其更改为position:static,它将跳回到该页面应显示的位置.或者,如果您要以某种方式对其进行动画处理,请先调用jQuery('#ImgCarouselCon').hide(),然后调用position:static(最好是通过执行该操作的CSS类),然后执行任何您想做的动画来显示它.

Then when you want to display it, just change it to position:static and it will jump back into where it should be for the page. Or if you're going to animate it somehow, call jQuery('#ImgCarouselCon').hide() first, then position:static (ideally through a CSS class that does that), then do whatever animation or whatnot you want to do to show it.

这篇关于页面加载时隐藏jCarousel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆