With a javascript dynamic variable, how to initialize slide/change event on jQuery slider?
I have: a GLOBAL, DYNAMIC vari开发者_StackOverflowable:
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.
You can use the value method
$('#slider').slider("value", 100);
精彩评论