HTML readOnly 屬性表示 input/textarea 元素是隻讀的,這意味著您不能在 HTML 文檔中修改其內容。
用法
以下是語法 -
<tagname readOnly></tagname>
讓我們看一個 HTML 隻讀屬性的例子 -
示例
<!DOCTYPE html>
<html>
<style>
body {
color:#000;
height:100vh;
background-color:#8BC6EC;
background-image:linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
text-align:center;
}
input {
display:block;
width:50%;
margin:1rem auto;
text-align:center;
}
</style>
<body>
<h1>HTML readOnly Demo</h1>
<input type="text" value="I'm an input element with readOnly property" readOnly>
</body>
</html>
輸出
相關用法
- HTML readonly屬性用法及代碼示例
- HTML reversed屬性用法及代碼示例
- HTML DOM removeAttributeNode()用法及代碼示例
- HTML referrerpolicy屬性用法及代碼示例
- HTML DOM removeAttribute()用法及代碼示例
- HTML DOM requestFullscreen()用法及代碼示例
- HTML DOM removeChild()用法及代碼示例
- HTML DOM removeNamedItem()用法及代碼示例
- HTML DOM renameNode()用法及代碼示例
- HTML DOM removeEventListener()用法及代碼示例
- HTML required屬性用法及代碼示例
- HTML reserved屬性用法及代碼示例
- HTML rel屬性用法及代碼示例
- HTML DOM replaceChild()用法及代碼示例
- HTML rowspan屬性用法及代碼示例
- HTML rowspan屬性用法及代碼示例
- HTML rows屬性用法及代碼示例
- HTML rows屬性用法及代碼示例
- HTML Dialog open用法及代碼示例
注:本文由純淨天空篩選整理自AmitDiwan大神的英文原創作品 HTML readOnly Attribute。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。