stop settimeout in recursive function

后端 未结 7 2083
旧时难觅i
旧时难觅i 2020-12-01 11:24

my problem is that I can not stop a timer.

I had this method to set a timeout from this forum. It supposed to store the identifyer in the global variable. By accid

相关标签:
7条回答
  • 2020-12-01 12:08

    As written mytimer is a function which never has the value of a timeout identifier, therefore your clearTimeout statement will achieve nothing.

    I don't see any recursion here at all, but you need to store the value setTimeout returns you, and if you need to pair this with multiple potential events you need to store it against a key value you can lookup - something like an element id perhaps?

    0 讨论(0)
提交回复
热议问题