// Like on(), but each element's handler runs at most once
eles.one(events: string, callback?: EventHandler<NodeData, EdgeData>): thisLike on(), but each element's handler runs at most once.
| Name | Description |
|---|---|
events: string | one or more space-separated event names |
callback: EventHandler<NodeData, EdgeData>? | the handler |
Returns
thisthis collection, for chaining
Example
let count = 0;cy.getElementById('a').one('example', () => count++);cy.getElementById('a').emit('example');cy.getElementById('a').emit('example');console.log(count); // 1Also spelled eles.once.