Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zh-cn: update the translation of the HTMLElement.click() method #23634

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions files/zh-cn/web/api/htmlelement/click/index.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
---
title: HTMLElement.click()
title: HTMLElementclick() 方法
slug: Web/API/HTMLElement/click
l10n:
sourceCommit: bf0b6c9ae5845fdfca1398541ed26d9946db2495
---

{{ APIRef("HTML DOM") }}

**`HTMLElement.click()`** 方法可以用来模拟鼠标左键单击一个元素。

当在支持 `click()` 方法的元素上使用该方法(例如
{{HTMLElement("input")}}) ,将会产生该元素的一个点击事件。这个事件会冒泡上升到文档树(或事件链)中更高的元素,并触发它们的点击事件。
**`HTMLElement.click()`** 方法模拟鼠标单击元素。当在某个元素上调用时,会触发元素的 {{domxref("Element/click_event", "click")}} 事件(除非该元素设置了 [`disabled`](/zh-CN/docs/Web/HTML/Attributes/disabled) 属性)。

## 语法

```js-nolint
click()
```

### 参数

无。

### 返回值

无({{jsxref("undefined")}})。

## 示例

当鼠标移动过复选框时模拟一个点击事件
当鼠标移动过复选框时模拟鼠标点击事件

### HTML

Expand All @@ -28,7 +35,7 @@ click()
type="checkbox"
id="myCheck"
onmouseover="myFunction()"
onclick="alert('click event occurred')" />
onclick="alert('发生点击事件')" />
</form>
```

Expand All @@ -51,8 +58,8 @@ function myFunction() {

## 参见

- 有关的事件处理
- 有关的事件处理器

- {{domxref("GlobalEventHandlers.onclick")}}
- {{domxref("GlobalEventHandlers.ondblclick")}}
- {{domxref("GlobalEventHandlers.onauxclick")}}
- {{domxref("Element.click_event", "Element.onclick")}}
- {{domxref("Element.dblclick_event", "Element.ondblclick")}}
- {{domxref("Element.auxclick_event", "Element.onauxclick")}}