English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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.
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‹/›
All browsers fully support the click() method:
Method | |||||
click() | Yes | Yes | Yes | Yes | Yes |
Return Value: | None |
---|---|
DOM Version: | DOM 2Level |
HTML DOM Reference:onclick event