javascript - Timeout in Jquery to update the Dom? -
let's want change image source onclick , calculations. whats happening right source changes when the function exits. (dom busy?)
how can make image source updates right away , function proceeds while loop?
html:
<img src="http://goo.gl/l55g2p" id="imagesrc"> js:
$( "#imagesrc" ).click(function() { new_imgsrc="http://goo.gl/wbhyee"; $("#imagesrc").attr('src',new_imgsrc); test = 0 { test = test + 1; console.log(test); } while (test != 50000); }); here's jsfiddle.
not sure understand correctly use timeout:
settimeout(function() { //while loop here }, 1000); where 1000 means 1 second. shrink value doesn't wait long.
as click() has no callback oncomplete not sure of better way achieve this.
Comments
Post a Comment