使用 javascript 动态变量,如何初始化 jQuery 滑块上的滑动/更改事件?
我有: 全局动态变量:
var index=0;
数组:
var arr={ 1:"First", 2:"Second" };
函数:
>var UpdateFunc=函数(值){ arr[索引]=值; }
现在我有一个 jQuery 滑块,其滑块事件初始化如下:
$("#slider").slider({ change: function(evt, ui){ UpdateFunc(ui.value); });
在某些情况下,在调用 sliderchange 之前,VARIABLE 索引已更改,但在调试时,通过 sliderchange 调用的 UpdateFunc 始终为 0(第一次追加)。
所以我的问题是:如何动态初始化 jQuery 滑块的滑动/更改事件,例如在本例中使用动态变量索引?
谢谢并希望尽快收到您的回复。
I have:
a GLOBAL, DYNAMIC variable:
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").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).
So my question is: How to initialize slide / change event of jQuery slider DYNAMICALLY, such as with dynamic variable index in this case ?
Thanks and hope to get your responses soon.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用值方法
You can use the value method