jQuery/JavaScript:预加载时触发

发布于 2024-09-01 03:52:57 字数 308 浏览 1 评论 0原文

jQuery 有 .ready() 函数,但我不确定这是否是我需要的:

一旦加载文档(图像和所有,不仅仅是 DOM),我在 CSS 中设置默认背景图像(图像为 4 中的 1);我想开始预加载背景图像 4 中的 2。加载后,我想将图像 1 淡入图像 2。然后我想预加载下一个图像(4 中的 3),一旦加载,我想要从背景图像2淡入图像3,最后预加载图像4。加载图像4后,我想将图像3淡入图像4。之后,我想以设定的时间间隔在图像之间循环。

我会使用什么策略来解决这个问题? .load() 函数?

谢谢您的宝贵时间。

亲切的问候,
马吕斯

jQuery has the .ready() function, but I am unsure whether this is what I need:

I set a default background image in CSS (imange 1 out of 4), once document is loaded (images and all, not only DOM); I want to start preloading background image 2 out of 4. Once that is loaded, I want to fade image 1 into image 2. Then I want to preload the next image (3 out of 4), once that is loaded, I want to fade from background image 2 into image 3, and finally preload image 4. Once image 4 is loaded, i would like to fade image 3 into image 4. After that, I want to cycle between the images with a set time interval.

What strategy would I use to solve this? .load() function?

Thank you for your time.

Kind regards,
Marius

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绝情姑娘 2024-09-08 03:52:57

一旦成功加载最后一个页面元素,Jquery.ready() 或更好的 $() 将触发。从那里您可以继续运行一系列方法,每个方法都会触发传递给它的回调中的下一个方法。

Jquery.ready() or better yet $() will trigger once the last page element is successfully loaded. From there you can proceed to run a chain of methods, each method triggering the next in a callback passed to it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文