[英]With a javascript dynamic variable, how to initialize slide/change event on jQuery slider?
I have: a GLOBAL, DYNAMIC variable: 我有:GLOBAL,DYNAMIC变量:
var index=0;
an array: 数组:
var arr={ 1:"First", 2:"Second" };
a function: 功能:
var UpdateFunc=function(value){ arr[index]=value; };
Now I have a jQuery slider with slider event initialized as below: 现在,我有了一个带有如下所示的slider事件的jQuery滑块:
$("#slider").slider({ change: function(evt, ui){ UpdateFunc(ui.value); } });
In some case, before sliderchange invoked, VARIABLE index is changed, but as debugging, UpdateFunc invoked through sliderchange, is always 0 (the first time appending). 在某些情况下,在调用Sliderchange之前,会更改VARIABLE索引,但是在调试时,通过SliderChange调用的UpdateFunc始终为0(首次添加)。
So my question is: How to initialize slide / change event of jQuery slider DYNAMICALLY, such as with dynamic variable index in this case ? 所以我的问题是:如何动态地初始化jQuery滑块的slide / change事件,例如在这种情况下使用动态变量index?
Thanks and hope to get your responses soon. 谢谢,希望尽快得到您的答复。
您可以使用值方法
$('#slider').slider("value", 100);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.