+ 1
Why the value doesn't doesn't get cleared?, please help
I want to clear the input after the alert message when someone is trying to paste text in there but the text remains in the input although I did set it to empty after the alert! https://code.sololearn.com/W066tbojMumw/#html
3 Respostas
+ 5
setTimeout takes two(or more) arguments. First one is a callback function that will be called after X miliseconds. X is the second argument.
setTimeout first waits for all pending tasks. Then waits X milliseconds and calls the callback function.
In my code I used setTimeout (function,0) to wait for the paste event fulfillment. This way i cleared the input value 0 milliseconds(a bit more but as soon as js could) AFTER the value was pasted and updated.
+ 3
Because myFunction gets called just before the input value is updated.
Solutions:
https://code.sololearn.com/Wt6KflNXms6O/?ref=app
https://code.sololearn.com/WtLlQbo4GqtU/?ref=app
+ 1
Thank you so much Kevin Star ! The code works perfectly But could you please explain me what on earth is setTimeout doing on here?