Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. HTMLFieldSetElement
  4. elements

HTMLFieldSetElement: elements property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨April 2018⁩.

Theelements read-only property of theHTMLFieldSetElement interface returns anHTMLCollection object containing all form control elements (<button>,<fieldset>,<input>,<object>,<output>,<select>, and<textarea>) that are descendants of this field set.

You can access a particular form control in the returned collection by using either anindex or the element'sname orid attributes. If multiple form controls share the same name, as is common with a group of radio buttons, using the shared name returns the first element with that value.

Value

AnHTMLCollection.

Examples

html
<form>  <fieldset>    <legend>My fieldset</legend>    <p>      <label for="username">Username:</label>      <input type="text" name="username" />    </p>    <p>      <label for="password">Password:</label>      <input type="password" name="password" />    </p>    <p>      <input type="checkbox" name="remember-me" />      <label for="remember-me">Remember me</label>    </p>  </fieldset></form>
js
const fieldset = document.getElementById("my-fieldset");console.log(fieldset.elements.length); // 3console.log(fieldset.elements["remember-me"].value); // "on"

Specifications

Specification
HTML
# dom-fieldset-elements-dev

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp