jQuery,根据父级获取拖动上的上一个和下一个元素

发布于 2024-09-10 14:12:59 字数 305 浏览 2 评论 0原文

我正在尝试创建一个时间表。有一个拖动器元素和一些动态创建的时间范围(DIV)。当您拖动拖动器时,代码将指示左近和右近的 div 是什么。该代码有效,您可以在 http://jsfiddle.net/3pXC9/15/ 中查看它。只需拖动红色手柄即可,蓝点在左,红点在右。

问题是我只需要为具有相同父级、相同层的元素获取下一个左侧和右侧。现在代码正在从两个层获取所有关键帧元素。 有办法做到这一点吗?如何获取具有相同父级的下一个和上一个元素?

I am trying to create a timeline. There is a dragger element and some dynamically created timeframes (DIVs). When you drag the dragger the code will indicate what is the near left and near right div. The code works, you can see it at http://jsfiddle.net/3pXC9/15/ . Just drag the red handle, the blue dot is the left and the red is the right.

The problem is that I need to get the next left and right only for elements that have the same parent, same layer. Right now the code is getting all the keyframes elements from both layers.
Is there a way to do that? How can I get the next and previous element that have the same parent?

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

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

发布评论

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

评论(1

悲欢浪云 2024-09-17 14:12:59

这是你想要的吗?

http://jsfiddle.net/3pXC9/17/

我分离了选择最接近关键帧的函数然后将图层的容器作为参数发送。

Is this what you want?

http://jsfiddle.net/3pXC9/17/

I separated the function that selects the closest keyframes and then you send in the container for the layer as a parameter.

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