English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML DOM click() Method

HTML DOM Element Object

click()The method simulates a mouse click on the element.

This method can be used to perform a click on an element as if the user clicks it manually.

When used with supported elements (such as <input>), click() will trigger the click event of the element. Then, this event bubbles up to the higher elements in the document tree (or event chain) and triggers their click events.

Syntax:

HTMLElement.click()
<button id="btn" onclick="alert(&"39;Click event occurs39;)" onmouseover="myFunc()">
Hover over me
</button>
<script>
function myFunc() {
   document.getElementById("btn").click();
}
</script>
Test See‹/›

Browser Compatibility

All browsers fully support the click() method:

Method
click()YesYesYesYesYes

Technical Details

Return Value:None
DOM Version:DOM 2Level

Related References

HTML DOM Reference:onclick event

HTML DOM Element Object