How to apply a timeout if a function hasn't been called 1 of N records in 3 seconds

后端 未结 2 1577
Happy的楠姐
Happy的楠姐 2021-01-26 12:39

When a user performs a certain action (typing) I run a function that applies a specific styling to that user in a list of 100s of users. As the user continues to type this funct

2条回答
  •  臣服心动
    2021-01-26 13:23

    Need to see some code to be sure, but it seems you could use setTimeout() (see reference here) with each function call, clearing the old timeout with clearTimeout() (see reference here) at the beginning of the function.

提交回复
热议问题