Run javascript function only once

后端 未结 3 2018
不知归路
不知归路 2020-12-10 21:48

I have this simple javascript function:



        
3条回答
  •  无人及你
    2020-12-10 22:21

    What you need is .one() function. It makes sure the code is triggered only once for you.

    Docs: http://api.jquery.com/one/

    Docs example:

    $( "#foo" ).one( "click", function() {
      alert( "This will be displayed only once." );
    });
    

提交回复
热议问题