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]: create docs for HTMLLabelElement #22816

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
32 changes: 32 additions & 0 deletions files/zh-cn/web/api/htmllabelelement/control/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: HTMLLabelElement:control 属性
slug: Web/API/HTMLLabelElement/control
l10n:
sourceCommit: d16706e4e930c57161d473287374a9286c663147
---

{{APIRef("HTML DOM")}}

只读的 **`HTMLLabelElement.control`** 属性返回控件(以类型 {{domxref("HTMLElement")}} 对象的形式或其衍生物之一)与 {{HTMLElement("label")}} 元素相关的引用,如果标签未与控件关联,则为 `null`。
fuchunhui marked this conversation as resolved.
Show resolved Hide resolved

## 值

{{domxref("HTMLElement")}} 派生对象,表示与 {{HTMLElement("label")}} 关联的控件,如果标签是单独的,则为 `null`。

> [!NOTE]
> 如果这个属性有值且 {{domxref("HTMLLabelElement.htmlFor")}} 有值,{{domxref("HTMLLabelElement.htmlFor")}} 属性必须指的是相同的控件。
fuchunhui marked this conversation as resolved.
Show resolved Hide resolved

## 规范

{{Specifications}}

## 浏览器兼容性

{{Compat}}

## 参见

- {{domxref("HTMLLabelElement")}}
- {{domxref("HTMLElement")}}
- {{HTMLElement("label")}}
- [HTML forms guide](/zh-CN/docs/Learn/Forms)
fuchunhui marked this conversation as resolved.
Show resolved Hide resolved
29 changes: 29 additions & 0 deletions files/zh-cn/web/api/htmllabelelement/form/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: HTMLLabelElement:form 属性
slug: Web/API/HTMLLabelElement/form
l10n:
sourceCommit: 595cba0e07c70eda7f08a12890e00ea0281933d3
---

{{APIRef("HTML DOM")}}

只读的 **`HTMLLabelElement.form`** 属性返回 {{domxref("HTMLFormElement")}} 对象表示与标签控件关联的表单,如果没有关联的控件,或者该控件未与表单关联,则是 `null`。这个属性是 `HTMLLabelElement.control.form` 的快捷方式。
fuchunhui marked this conversation as resolved.
Show resolved Hide resolved

## 值

{{domxref("HTMLFormElement")}} 表示与标签 {{domxref("HTMLLabelElement.control", "control")}} 关联的表单。如果 {{domxref("HTMLLabelElement.control", "control")}} 是 `null`(意味标签与控件无关),或者如果控件不是表单的部分,属性返回 `null`。
fuchunhui marked this conversation as resolved.
Show resolved Hide resolved

## 规范

{{Specifications}}

## 浏览器兼容性

{{Compat}}

## 参见

- {{domxref("HTMLLabelElement")}}
- {{domxref("HTMLElement")}}
- {{HTMLElement("label")}}
- [HTML forms guide](/zh-CN/docs/Learn/Forms)
fuchunhui marked this conversation as resolved.
Show resolved Hide resolved
33 changes: 33 additions & 0 deletions files/zh-cn/web/api/htmllabelelement/htmlfor/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: HTMLLabelElement:htmlFor 属性
slug: Web/API/HTMLLabelElement/htmlFor
l10n:
sourceCommit: d16706e4e930c57161d473287374a9286c663147
---

{{APIRef("HTML DOM")}}

**`HTMLLabelElement.htmlFor`** 属性反映 [`for`](/zh-CN/docs/Web/HTML/Element/label#for) 内容属性的值。意味着此脚本可访问属性用于设置和读取内容属性 `for` 的值,该属性是相关控件元素的 ID。
fuchunhui marked this conversation as resolved.
Show resolved Hide resolved

## 值

包含与控件相关元素 ID 的字符串。

> [!NOTE]
> 如果属性有值,{{domxref("HTMLLabelElement.control")}} 属性必须指的是相同的控件。
fuchunhui marked this conversation as resolved.
Show resolved Hide resolved

## 规范

{{Specifications}}

## 浏览器兼容性

{{Compat}}

## 参见

- {{domxref("HTMLLabelElement")}}
- {{domxref("HTMLLabelElement.control")}}
- {{domxref("HTMLElement")}}
- {{HTMLElement("label")}}
- [HTML forms guide](/zh-CN/docs/Learn/Forms)
fuchunhui marked this conversation as resolved.
Show resolved Hide resolved
44 changes: 44 additions & 0 deletions files/zh-cn/web/api/htmllabelelement/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: HTMLLabelElement
slug: Web/API/HTMLLabelElement
l10n:
sourceCommit: d16706e4e930c57161d473287374a9286c663147
---

{{ APIRef("HTML DOM") }}

**`HTMLLabelElement`** 接口允许访问特定于 {{HTMLElement("label")}} 元素的属性,它基于 {{domxref("HTMLElement")}} 接口继承方法和属性。
fuchunhui marked this conversation as resolved.
Show resolved Hide resolved

{{InheritanceDiagram}}

## 实例属性

_从其父接口 {{domxref("HTMLElement")}} 继承属性。_

- {{domxref("HTMLLabelElement.control")}} {{ReadOnlyInline}}
- : {{domxref("HTMLElement")}} 表示与标签关联的控件。
fuchunhui marked this conversation as resolved.
Show resolved Hide resolved
- {{domxref("HTMLLabelElement.form")}} {{ReadOnlyInline}}
- : {{domxref("HTMLFormElement")}} 对象表示与标签控件关联的表单,如果没有关联的控件,或者该控件未与表单关联,则是 `null`。换句话说,这只是 `HTMLLabelElement.control.form` 的快捷方式。
yin1999 marked this conversation as resolved.
Show resolved Hide resolved
- {{domxref("HTMLLabelElement.htmlFor")}}
- : 包含标签控件 ID 的字符串,反映 [`for`](/zh-CN/docs/Web/HTML/Element/label#for) 属性。
fuchunhui marked this conversation as resolved.
Show resolved Hide resolved

> [!NOTE]
> 以变成方式设置 `for` 属性,使用 [`htmlFor`](/zh-CN/docs/Web/API/HTMLLabelElement/htmlFor)。
fuchunhui marked this conversation as resolved.
Show resolved Hide resolved

## 实例方法

_没有特定的方法,从其父接口 {{domxref("HTMLElement")}} 继承方法。_

## 规范

{{Specifications}}

## 浏览器兼容性

{{Compat}}

## 参见

- 实现此接口的 HTML 元素:{{HTMLElement("label")}}
- {{HTMLElement("form")}}
- {{domxref("HTMLFormElement")}}