javascript - How to take a value from one jQuery function and assign it to a parameter of another function? -
i have function jquery slider. sets delay time , shows in "#slider" div :
$(function () { $("#slider").slider({ range: 'max', min: 1, max: 5, slide: function(event,ui) { $("#delaytime").val(ui.value); delaytime = ui.value * 1000; } }); });
this works ok itself.
later in code have function runs whole slideshow. function has own parameter determines delay time between each slide:
function myslideshow(){ var wholeslideshow = $('#thumbholder').gallerywithslideshow({ maincntrls: true, prevnextcntrls: true, delaytime: 2000, etc. });
this 1 works fine too.
question.
what should add code pass value in slider function slideshow function's delaytime parameter slider function determine delaytime in slideshow function?
i considering modifying slider function this:
$(function () { $("#slider").slider({ range: 'max', min: 1, max: 5, slide: function(event,ui) { $("#delaytime").val(ui.value); delaytime = ui.value * 1000; return delaytime; } }); });
as adding slideshow function's delaytime parameter this:
delay: function (event, ui){ $("#delaytime").val(delaytime); },
although not make work.
any ideas? appreciate help.
declare variable mydelaytime before, outside functions. accessible throughout code.
var mydelaytime; $(function () { $("#slider").slider({ range: 'max', min: 1, max: 5, slide: function(event,ui) { $("#delaytime").val(ui.value); delaytime = ui.value * 1000; mydelaytime = delaytime; } }); }); ... delay: function (event, ui){ $("#delaytime").val(mydelaytime); },
Comments
Post a Comment