简体   繁体   中英

With a javascript dynamic variable, how to initialize slide/change event on jQuery slider?

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.

您可以使用值方法

$('#slider').slider("value", 100);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM