You are here: Reference > JavaScript > client-side > event handling > methods > click

click method

Browser support:
Simulates a mouse click on the current element.
Simulating a click event on an element with the click method causes the default action of the event to be performed, but the element does not get the focus. For example, invoking the click method on a checkbox toggles its checked state, invoking the click method on an input field does not cause the input field to get the focus.
  • If you need to simulate other events, see the page for the dispatchEvent and fireEvent methods.
  • To set or remove the focus from an element, use the focus and blur methods.
  • In Internet Explorer, if you want to simulate a mouse click on a scrollbar component of an element, use the doScroll method.

Syntax: ( );
You can find the related objects in the Supported by objects section below.

Return value:

This method has no return value.

Example HTML code 1:

This example illustrates the use of the click method:
    <script type="text/javascript">
        function InitClick (checkbox) {
    <input type="checkbox" onmouseover="InitClick (this);" onclick="alert ('click event occurred')"/>Hover over the check box!
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content