execute a function only once

后端 未结 3 984
南旧
南旧 2020-12-22 04:14

I have a function which executes on click event, but the thing is that I want it to execute only once.

The function that get\'s executed on click represents a googl

3条回答
  •  长情又很酷
    2020-12-22 05:19

    Use jQuery's .one().

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

    As per OP's explanation: there's always the possibility to define more than one click event for an element.

    So you can define one with .one() and the other with on() as you already do, putting the code to run only once in the first.

提交回复
热议问题