javascript - How to run through a function again once it reaches the end? -


how run through loop again once reaches last value in array?

i run function init() again once completed because more dom elements myelement ajaxed in once have been clicked on.

i have tried running init function after settimeout doesnt work , tried checking last element on array btn.length -1 still doesnt work.

function dosettimeout(index, btn) {      settimeout(function() {          jquery(btn[index]).click();      }, index  * 1500);      //init();     }  function init() {      var btn = [].slice.call(document.queryselectorall('.myelement'));      var index;      (index = 0; index < btn.length; index++) {          dosettimeout(index, btn)      }  }  init(); 

does work?

function init() {      var btn = [].slice.call(document.queryselectorall('.myelement'));      var index = 0;      function click() {       settimeout(function() {           if(index < btn.length) {             jquery(btn[index++]).click();             click();           } else {             init();           }       }, 1500);     }     click(); } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -