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

New pages: HTML<formelements>Element.value properties #35641

Merged
merged 4 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
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
36 changes: 36 additions & 0 deletions files/en-us/web/api/htmlbuttonelement/value/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: "HTMLButtonElement: value property"
short-title: value
slug: Web/API/HTMLButtonElement/value
page-type: web-api-instance-property
browser-compat: api.HTMLButtonElement.value
---

{{ APIRef("HTML DOM") }}

The **`value`** property of the {{DOMxRef("HTMLButtonElement")}} interface represents the value of the {{htmlelement("button")}} element as a string, or the empty string if no value is set. It reflects the element's [`value`](/en-US/docs/Web/HTML/Element/button#value) attribute.

## Value

A string containing the value of the {{htmlelement("button")}} element.

## Examples

```js
const buttonElement = document.getElementById("givenname");
console.log(`value: ${buttonElement.value}`);
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{HTMLElement("button")}}
- {{DOMXref("HTMLButtonElement.type")}}
- {{DOMXref("HTMLButtonElement.labels")}}
38 changes: 38 additions & 0 deletions files/en-us/web/api/htmloptionelement/value/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: "HTMLOptionElement: value property"
short-title: value
slug: Web/API/HTMLOptionElement/value
page-type: web-api-instance-property
browser-compat: api.HTMLOptionElement.value
---

{{ APIRef("HTML DOM") }}

The **`value`** property of the {{DOMxRef("HTMLOptionElement")}} interface represents the value of the {{htmlelement("option")}} element as a string, or the empty string if no value is set. It reflects the element's [`value`](/en-US/docs/Web/HTML/Element/option#value) attribute, if present. Otherwise, it returns or sets the contents of the element, similar to the {{domxref("Node.textContent","textContent")}} property.

## Value

A string containing the `value` attribute value, if present, or the contents of the element.

## Examples

```js
const optionElement = document.querySelector("datalist option:first-of-type");
const oldValue = optionElement.value;
optionElement.value = oldValue.toUpperCase();
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{HTMLElement("option")}}
- {{DOMXref("HTMLOptionElement.selected")}}
- {{DOMXref("HTMLOptionElement.defaultSelected")}}
- {{DOMXref("HTMLOptionElement.label")}}
40 changes: 40 additions & 0 deletions files/en-us/web/api/htmloutputelement/value/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: "HTMLOutputElement: value property"
short-title: value
slug: Web/API/HTMLOutputElement/value
page-type: web-api-instance-property
browser-compat: api.HTMLOutputElement.value
---

{{ APIRef("HTML DOM") }}

The **`value`** property of the {{DOMxRef("HTMLOutputElement")}} interface represents the value of the {{htmlelement("output")}} element as a string, or the empty string if no value is set. It returns or sets the contents of the element, similar to the {{domxref("Node.textContent","textContent")}} property.

> [!NOTE]
> When the `value` property of an `<output>` element is set, the element goes into value mode and the default value is accessible only through the {{DOMXref("HTMLOutputElement.defaultValue")}} property.

## Value

A string containing the contents of the {{htmlelement("output")}} element.

## Examples

```js
const outputElement = document.getElementById("log");
console.log(`value: ${outputElement.value}`);
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{HTMLElement("output")}}
- {{DOMXref("HTMLOutputElement.defaultValue")}}
- {{DOMXref("HTMLOutputElement.labels")}}
- {{DOMXref("HTMLOutputElement.htmlFor")}}
39 changes: 39 additions & 0 deletions files/en-us/web/api/htmltextareaelement/value/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: "HTMLTextAreaElement: value property"
short-title: value
slug: Web/API/HTMLTextAreaElement/value
page-type: web-api-instance-property
browser-compat: api.HTMLTextAreaElement.value
---

{{ APIRef("HTML DOM") }}

The **`value`** property of the {{DOMxRef("HTMLTextAreaElement")}} interface represents the value of the {{htmlelement("textarea")}} element as a string, which is an empty string if the widget contains no content. It returns or sets the raw value contained in the control.

## Value

A string containing the contents of the {{htmlelement("textarea")}} element.

## Examples

```js
const textareaElement = document.getElementById("comment");
const oldText = textArea.value;
textArea.value = oldText.toUpperCase();
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{HTMLElement("textarea")}}
- {{DOMXref("HTMLTextAreaElement.textLength")}}
- {{DOMXref("HTMLTextAreaElement.labels")}}
- {{DOMXref("HTMLTextAreaElement.selectionStart")}}
- {{DOMXref("HTMLTextAreaElement.selectionEnd")}}