简单的 jQuery Animate 示例 - 从一个 div 滚动到另一个 div
这是我要创建的示例...
假设有两个 div,每个 div 都包含一些其他 HTML/内容(其他 div)。我希望在页面加载时在视图中显示其中一个 div,然后在几秒后(假设是 5 秒),将第二个 div 滚动到与第一个 div 相同的位置,然后无限期地重复该过程,直到用户离开页面。
相关页面和元素可以在 http://paysonfirst assembly.com/ 中找到。我正在尝试使用一类dynamicPanel 为左侧边栏设置动画。至少有三个这样的 div,它们的内容长度几乎匹配。
我感谢大家的帮助。我是一名非常新的客户端程序员,并且很欣赏这个社区对新开发人员的尊重。
Here is the example I'm looking to create...
Let's assume there are two divs, each containing some other HTML/Content (other divs). I would like to have one of these divs in the view on page load, and then after some number of seconds (let's say 5), scroll the second div onto the same place as the first div, and then repeating that process indefinitely until the user leaves the page.
The page and elements in question can be found at http://paysonfirstassembly.com/. I am attempting to animate the left sidebar with a class of dynamicPanel. There will be at least three of these divs, and they will nearly match up in content length.
I appreciate everybody's help. I am a very new client-side programmer and appreciate the respect that this community has with new developers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下内容的工作演示 →
这是我刚刚制作的一个简单的 jQuery 插件将向上滑动第一个 div 并将其放置在列表的末尾。我对下面的代码进行了注释以进一步解释,以便您可以开始使用,您可以根据您的需要进行调整并了解 jQuery:
如果您想更改延迟,您可以将其作为选项传递:
注意:我还将
.dynPanelOpener
和.dynPanelTitle
移至.dynPanelContent
中,以便将它们包含在动画中。查看工作示例→
Working demo of the following →
Here's a simple jQuery plugin I just made that will slide up the first div and place it at the end of the list. I've commented the code below to further explain so that this can just get you started and you can adjust it to your needs and learn about jQuery:
If you want to change the delay you can just pass it in as an option:
Note: I also moved
.dynPanelOpener
and.dynPanelTitle
within.dynPanelContent
so that they're included in the animations.See working example →