CKTIS / JavaScript
HTMLElement.click — programmatic clicking
HTMLElement.click triggers a synthetic click on an HTML element. It is neither a physical click nor a source of user activation.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
element.click()Call HTMLElement.click as element.click(), without arguments; it returns undefined. This is a browser API defined by the HTML Standard, not an ECMAScript function. Current browser engines support it; Node 24 does not establish its availability.
The method synchronously dispatches a synthetic click event with isTrusted === false. It can trigger the element's default activation behavior. It neither focuses the element nor itself supplies user activation required by protected APIs.
For a disabled form control, the method does nothing. A reentrant call on the same element during an ongoing click() is also ignored. The example demonstrates both cases; the element need not be attached to the document.
Examples
const button = document.createElement('button');
button.type = 'button';
let count = 0;
button.addEventListener('click', (event) => {
count += 1;
console.log(`click ${count}; trusted=${event.isTrusted}`);
button.click(); // Reentrant call is ignored.
});
button.click();
button.disabled = true;
button.click();
console.log(`total=${count}`);Result
click 1; trusted=false total=1
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.