.one(events ,selector ,data ,$)
Description:
Attach the jQuery chain behind to one or more events. It is executed at most once per element.
- events –
string
- One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
- selector –
string
, optional - A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
- data –
object
, optional - A map of data that will be passed to the event handler.
- $ – the
jQuery
token, optional - Use $ instead of a handler or leave it out.
Examples with timed version of .one()
Example #12: cyclic button clicks
The buttons can be clicked one after the other. At the end the cycle starts over and over.
Remark that the code is the same no matter how many buttons we have.
⇒