Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. HTMLInputElement
  4. readOnly

HTMLInputElement: readOnly property

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.

ThereadOnly property of theHTMLInputElement interface indicates that the user cannot modify the value of the<input>. It reflects the<input> element'sreadonly boolean attribute; returningtrue if the attribute is present andfalse when omitted.

Unlike a form control with a truedisabled property, a truereadOnly property value does not prevent the user from clicking or selecting in the control.

While the HTMLreadonly attribute is ignored if the type ishidden,range,color,checkbox,radio,file,submit,reset,button, andimage, thereadOnly property istrue for these input types if the attribute is present,false otherwise.

Value

A boolean.

Examples

js
const inputElement = document.getElementById("total");console.log(inputElement.readOnly);inputElement.readOnly = true;

Specifications

Specification
HTML
# dom-input-readonly

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp