How to execute Jquery code only once??

后端 未结 9 2069
梦谈多话
梦谈多话 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条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 16:33

    Use a boolean as a global variable, like

    var flag = true;
    

    Now, set the condition before the execution, Like

    if(flag){  
       $("#loadingMessage").css('padding-top','6%');  
       flag=false;  
    }
    

提交回复
热议问题