HTMLElement: click() メソッド
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
HTMLElement.click()
メソッドは、要素のマウスクリックをシミュレートします。要素上で呼び出されると、その要素の click
イベントが発生します(disabled
属性が設定されている場合を除く)。
構文
js
click()
引数
なし。
返値
なし (undefined
)。
例
チェックボックスの上にマウスポインターを移動させたときのマウスクリックをシミュレートします。
HTML
html
<form>
<input
type="checkbox"
id="myCheck"
onmouseover="myFunction()"
onclick="alert('click event occurred')" />
</form>
JavaScript
js
// マウスオーバーで、myFunction を実行する
function myFunction() {
document.getElementById("myCheck").click();
}
仕様書
Specification |
---|
HTML # dom-click-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
click |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
関連情報
-
関連するイベントハンドラー