Function: onClick()
Overload 1
onClick(
element,callback):void
Defined in: interaction.ts:31
Registers a callback to be invoked when the given element is clicked.
Parameters
element
HTMLElement
The target element.
callback
The function to call when the element is clicked.
Returns
void
Example
// HTML
<button id="my-button">Click Me!</button>
// JS
const btn = facile.getElement('#my-button');
facile.onClick(btn, () => facile.say('Clicked!'));Overload 2
onClick<
K>(tag,callback):void
Defined in: interaction.ts:44
Registers a callback to be invoked when the first element matching the given tag name is clicked. Does nothing if no element is found.
Type Parameters
K
K extends keyof HTMLElementTagNameMap
Parameters
tag
K
The HTML tag name to search for.
callback
The function to call when the element is clicked.
Returns
void
Example
// HTML
<button>Click Me!</button>
// JS
facile.onClick('button', () => facile.say('Clicked!'));Overload 3
onClick(
selector,callback):void
Defined in: interaction.ts:57
Registers a callback to be invoked when the first element matching the given CSS selector is clicked. Does nothing if no element is found.
Parameters
selector
string
A CSS selector string.
callback
The function to call when the element is clicked.
Returns
void
Example
// HTML
<button id="my-button">Click Me!</button>
// JS
facile.onClick('#my-button', () => facile.say('Clicked!'));