Favorites

DOM HTMLElement.click() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
HTMLElement.click()
DOM HTMLElement MethodThis method is supported by all modern browsers.
Updated 28th November 2026

The click() method simulates a mouse click on an element, firing its click event and running its default action.

Description

The click() method simulates a click on the element. It fires a click event that bubbles, and runs the element's default action, such as toggling a checkbox, submitting a form or opening a file picker for a file input. It doesn't move focus. It's commonly used to trigger a hidden file input from a styled button.

Because it runs the default action, calling click() on a submit button submits its form, on a link navigates, and on a label activates its associated control. Disabled form controls ignore it.

Browsers treat a click() call made inside a real user's click or key handler as part of that user action, so things like opening a file picker work. Called later, from a timer for example, some actions such as opening popups may be blocked.

Syntax

element.click()

Return Value

None (undefined).

Example

<label><input type="checkbox" id="agree"> I agree</label>
const check = document.getElementById('agree');
check.addEventListener('click', () => console.log('checked:', check.checked));
check.click();
check.click();

Browser Support

The following information will show you the current browser support for the HTMLElement.click() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee