jQuery相互依赖的滑块

时间:2013-08-23 10:46:53

标签: javascript jquery slider

http://oi42.tinypic.com/2myduur.jpg

我有滑块:“数量”,“unitprice”,“折扣”

如果我滑动数量(数量有值X),我需要更改滑块“unitprice”值= X + 5.

$(".quantity_{/literal}{$value['idProduct']}{literal}").empty().slider({
orientation: "vertical",
range: "min",
min: 0,
max: 100,
value: 0,
slide: function(event, ui)
{
$("#quantity_{/literal}{$value['idProduct']}{literal}").val(ui.value);
}
}).bind('slide slidechange', function(event,ui) {
/* Here is the problem, Here i can set value on slider change for input fields and other, but for slider I cant */ });

2 个答案:

答案 0 :(得分:2)

试试这段代码

 $(".selector").slider("value", parseInt(ui.value)+5);

答案 1 :(得分:0)

来自文档的问候:http://api.jqueryui.com/slider/#option-value

$(".selector").slider("option", "value", 10);

代码示例:http://jsfiddle.net/kdPZt/3/