How to execute Jquery code only once??

后端 未结 9 2079
梦谈多话
梦谈多话 2020-12-16 15:52

I have one jquery method and i used call that method on click of a button . So in that code i have one line \" $(\"#loadingMessage\").css(\'padding-top\',\'6%\');

9条回答
  •  萌比男神i
    2020-12-16 16:23

    you can use js closure to slove the question.

    function once(func) {
        let isExeced = false;
        return function(...arg) {
            if (isExeced) return void 0;
            isExeced = true;
            func.apply(null, arg)
        }
    }
    

提交回复
热议问题