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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -