动态增加和减少 jQuery 滑块值
我在 jQuery 滑块方面遇到了一些问题。 我在这里查看了几个例子,人们似乎在问同样的问题,但给出的批准答案从未达到他们实际要求的。因此我开始了我自己的线程。
我正在尝试生成一组最大总值为 1500 的 jQuery 滑块。如果一个滑块 (sliderA) 移动到 700,则其他滑块 (B、C、D) 的最大总值必须调整为 800如果其他滑块都没有被移动并且如此处找到的代码那样为零,那么这很好。 rel="nofollow">jsFiddle 的技巧是确保其余滑块不能超过 800(无论是 400、400、0 还是 500、150、150 分割)。真正的问题是,如果调整每个滑块后的总值超过总体 1500 的限制,我需要动态减小滑块。
例如: 我将滑块 A 移至 900。 滑块 B 开始时设置为 500。 滑块 C 开始时设置为 300。 滑块 D 未设置。
滑块 B 和 C 应根据滑块 A 处的值按比例减少,以便总数不会超过 1500 的限制。
有什么想法吗?
I am having a bit of an issue with regards to jQuery sliders.
I've looked around on here at several examples where people seem to be asking the same question but the approved answers given never achieve what they are actually asking for. I've therefore started my own thread.
I am trying to generate a set of jQuery sliders that have a maximum total value of 1500. If one slider (sliderA) is moved to 700, the maximum total value of the other sliders (B,C,D) must be adjusted to 800. This is fine if none of the other sliders have already been moved and are at zero as the code found here jsFiddle does the trick to ensure that the rest of the sliders cannot go over 800 (whether it be a 400, 400, 0 or 500 , 150, 150 split). The real issue is that I need the sliders to decrease dynamically if the total value after each slider is adjusted surpasses the overall 1500 limit.
For example:
I move Slider A to 900.
Slider B was set to 500 to start with.
Slider C was set to 300 to start with.
Slider D was not set.
Sliders B and C should decrease proportionally based upon the value at slider A so that the overall total never surpasses the 1500 limit.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是您正在寻找的确切(完美)解决方案,但我认为它为您提供了一个开始的想法,我猜:
在 jsfiddle 上查看。
This is not the exact (perfect) solution you are looking for, but I think it kind of gives you an idea to get started I guess:
See it on jsfiddle.
这看起来是一个非常令人困惑的功能。我试图想象什么样的用户界面需要多个滑块之间如此复杂的关系。
有没有一种方法可以简化用户界面,从而从一开始就避免这个问题?
This seems like very confusing functionality. I am trying to picture what kind of user interface would need such complicated relationships between multiple sliders.
Is there a way to simplify the user interface that would perhaps avoid this issue in the first place?