0

I have a function

Plus() {
    document.getElementsByClassName('like hintable')[0].click(); Hide();alert ("test") ;
}

How could I run document.getElementsByClassName('like hintable')[0].click()
after two seconds run Hide() after two other seconds run alert.

Is there any way without creating 3 functions and use setTimeOut .

Simpal Kumar
  • 3,331
  • 3
  • 23
  • 47
a_barsa
  • 1
  • 3

1 Answers1

0

You cannot use sleep/delay/wait in a function to pause Javascript unfortunately.

You have to use setTimeout()

SO - Source 1

SO - Source 2

Community
  • 1
  • 1
Simpal Kumar
  • 3,331
  • 3
  • 23
  • 47