How do you handle multiple instances of setTimeout()?

前端 未结 9 2040
鱼传尺愫
鱼传尺愫 2020-12-01 05:18

What is the most recommended/best way to stop multiple instances of a setTimeout function from being created (in javascript)?

An example (psuedo code):



        
9条回答
  •  天命终不由人
    2020-12-01 06:14

    you can always overwrite the buttons onclick to return false. example:

    
    
        Javascript example
        
    
    
        

    Javascript example

    Should Only Fire Once

提交回复
热议问题