+ 1

Why i cant call function setTimeout

im try call setTimeout on <button, onclick="setTimeout(next(), 10000);> but it didnt work, cant understant why. function next change imgs src.

28th Sep 2017, 10:30 PM
Artem
4 Answers
+ 5
drop the () on next, otherwise it will *immediately* evaluate the output of next() -- does it return anything, or 'undefined'? -- and then attempt to start whatever that output is 10 seconds later.
28th Sep 2017, 10:58 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
Did the question text change?
29th Sep 2017, 2:12 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
Hi you have missed out double quote at the end of onclick
29th Sep 2017, 10:24 AM
Khun Ling Tan
Khun Ling Tan - avatar
0
Did you wait 10 seconds? Can you show the next() function()?
28th Sep 2017, 10:45 PM
Anton Bojik
Anton Bojik - avatar