javascript - Why do for loop executes before Jquery Selector in this code? -
in code below for
loop executes first, jquery selector comes later. want run loop after changing value of selected sliders.
$('div[name="firstsliderselector"]').slider('value', $("#masterslider").slider("value")); var firstsliders = $('div[name="firstsliderselector"]'); (var = 0; < firstsliders.length; i++) { console.log('for loop executed'); }
guaranteed run loop after slider assignment...
var firstsliders = $('div[name="firstsliderselector"]'), mastslidervalue = $("#masterslider").slider("value"); function updatesliders(){ firstsliders.slider('value', mastslidervalue); } $.when( updatesliders() ).done( function(){ (var = 0; < firstsliders.length; i++) { console.log('for loop executed'); } } );
thanks -1 on first attempt guys ;) new this.
Comments
Post a Comment