HTML DOM readOnly 属性

定义和用法

The readOnly property sets or returns whether or not a text area should be read only.

语法

textareaObject.readOnly=true|false

实例

The following example sets the text area to be read-only:

<html>
<head>
<script type="text/javascript">
function setReadOnly()
  {
  document.getElementById('txt1').readOnly=true;
  }
</script>
</head>
<body>

<textarea id="txt1">
Hello world....This is a text area
</textarea>
<br />
<input type="button" onclick="setReadOnly()" 
value="Make read-only" />

</body>
</html>