Prevent Javascript from being executed twice

前端 未结 5 1082
清歌不尽
清歌不尽 2020-12-19 13:04

I have a script that I am developing that creates a sliding button type effect. Five div\'s are situated next to eachother each with a link. When one of those DIVS are click

5条回答
  •  执念已碎
    2020-12-19 13:35

    (function() {
    var mutex = false;
    
        function mnuClick(x){
            if (!mutex) {
               mutex = !mutex;
    
               /* all code here ...   */
    
               mutex = !mutex; /* this statement should go into animation callback */
            }
    
        }
    
    })();
    

    mantain a state through a variable so you cannot click more than once until code has fully executed

提交回复
热议问题