DOM Methods

HTMLElement.click()

Build a form with the HTML form generator

Invokes synthetic click activation on an eligible element. Disabled form controls are excluded. It can activate checkboxes and buttons but does not create a trusted user gesture or synthesize a full pointer sequence. Example result: true.

Formal Syntax & Structure

html syntaxhtml
element.click()

Return Value

undefined

No return value.

Working Example

Example Snippethtml
<input id="demo" type="checkbox"><p>  Result:  <output id="result"></output></p><script>  const e = document.getElementById('demo');  const result = value => { document.getElementById("result").textContent = String(value); };  e.click(); result(e.checked);</script>
HTML Reference