Latest web development tutorials

HTML DOM Textarea defaultValue property

Textarea Object Reference Textarea object

Definition and Usage

defaultValue property sets or returns the initial contents of the text box.

Note: The initial value of the text is a text box located <textarea> and </ textarea> tags.When the form is reset, the text box will be restored to the entire value. Text change the value of the property will change the text box currently displayed.

grammar

Setting defaultValue property:

textareaObject.defaultValue="text"

Back defaultValue attributes:

textareaObject.defaultValue

Tip: defaultValue property has no default value.

描述
text 指定文本框的默认值


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support defaultValue property


Examples

Examples

The following examples suggest the default value of the text box:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult()
{
    alert(document.getElementById("myTextarea").defaultValue);
}
</script>
</head>
<body>

<textarea id="myTextarea" cols="20">
在本教程,你可以学多很多编程的基础知识,包括 HTML, XML, SQL, ASP, 和 PHP 等各种前端内容。
</textarea>
<br>

<button type="button" onclick="displayResult()">弹出默认值</button>

</body>
</html>



Textarea Object Reference Textarea object