Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1031932 of HTMLElement.click()

  • Revision slug: Web/API/HTMLElement/click
  • Revision title: HTMLElement.click()
  • Revision id: 1031932
  • Created:
  • Creator: rolfedh
  • Is current revision? No
  • Comment Editorial review. No changes.

Revision Content

{{ APIRef("HTML DOM") }}

The HTMLElement.click() method simulates a mouse click on an element.

When click is used with elements that support it (e.g., one of the {{HTMLElement("input")}} types listed above), it also fires the element's click event, which bubbles up to elements higher in the document tree (or event chain) and fires their click events, too. However, the bubbling of a click event does not cause an {{HTMLElement("a")}} element to initiate navigation as if a real mouse-click had been received.

Syntax

elt.click()

Specification

Specification Status Comment
{{SpecName('DOM2 HTML', 'html.html#ID-2651361')}} {{Spec2('DOM2 HTML')}} Initial definition

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 20[3] 5[1] {{CompatVersionUnknown}} {{CompatVersionUnknown}}[2] 6[3]
input@file (limited) {{CompatVersionUnknown}} 4 {{CompatVersionUnknown}} 12.10 {{CompatVersionUnknown}}
input@file (full) {{CompatVersionUnknown}} 4 {{CompatVersionUnknown}} {{CompatNo}} {{CompatVersionUnknown}}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{CompatNo}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

[1] Prior to Gecko 5.0 {{geckoRelease("5.0")}}, Gecko didn't implement the click method on other elements that might be expected to respond to mouse–clicks such as links ({{HTMLElement("a")}} elements), nor would it necessarily fire the click event of other elements.

[2] In Presto-based versions of Opera the click() method will silently be ignored if made on an {{HTMLElement("input")}} with its type attribute set to file and its CSS {{cssxref('display')}} property set to none.

[3] Older versions had HTMLInputElement.click(), and HTMLButtonElement.click() only.

Revision Source

<div>
<div>{{ APIRef("HTML DOM") }}</div>
</div>

<p>The <code><strong>HTMLElement.click()</strong></code> method simulates a mouse click&nbsp;on an element.</p>

<p>When <code>click</code> is used with elements that support it (e.g., one of the {{HTMLElement("input")}} types listed above), it also fires the element's click event, which bubbles up to elements higher in the document tree (or event chain) and fires their click events, too. However, the bubbling of a click event does not cause an {{HTMLElement("a")}} element to initiate navigation as if a real mouse-click had been received.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">
<em>elt</em>.click()</pre>

<h2 id="Specification">Specification</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('DOM2 HTML', 'html.html#ID-2651361')}}</td>
   <td>{{Spec2('DOM2 HTML')}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>20<sup>[3]</sup></td>
   <td>5<sup>[1]</sup></td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}<sup>[2]</sup></td>
   <td>6<sup>[3]</sup></td>
  </tr>
  <tr>
   <td><code>input@file (limited)</code></td>
   <td>{{CompatVersionUnknown}}</td>
   <td>4</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>12.10</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>input@file (full)</code></td>
   <td>{{CompatVersionUnknown}}</td>
   <td>4</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] Prior to Gecko 5.0 {{geckoRelease("5.0")}}, Gecko didn't implement the click method on other elements that might be expected to respond to mouse–clicks such as links ({{HTMLElement("a")}} elements), nor would it necessarily fire the click event of other elements.</p>

<p>[2] In Presto-based versions of Opera the <code>click()</code> method will silently be ignored if made on an {{HTMLElement("input")}} with its <code>type</code> attribute set to <code>file</code> and its <a href="/en-US/docs/Web/CSS">CSS</a> {{cssxref('display')}} property set to <code>none</code>.</p>

<p>[3] Older versions had <code>HTMLInputElement.click()</code>, and <code>HTMLButtonElement.click()</code> only.</p>
Revert to this revision