How to click in for loop iteration

9 Views Asked by At
var aa = document.querySelectorAll('.x5yr21d .xjkvuk6');
var i = 1; 
function myLoop() {         
  setTimeout(function() { 
    console.log(i); 
     console.log(aa[i]); 
    
// I want click here like
aa[i].click();
but above line of code does not work
    
         i++;               
    if (i < aa.length) {        
      myLoop();          
    }                   
  }, 3000)
}

myLoop();

For example I am getting all elements through classname and added delay using set timeout.

Now I want click on every element. How is it possible?

0

There are 0 best solutions below