Latest web development tutorials

HTML DOM Textarea value property

Textarea Object Reference Textarea object

Definition and Usage

value property sets or returns the text of the textarea.

grammar

Set the value property:

textareaObject.value="text"

Returns the value property:

textareaObject.value

描述
text 指定文本框的内容


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support attribute value


Examples

Examples

Pop-up text textarea elements:

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

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

<button type="button" onclick="displayResult()">弹出 textarea 元素的文本</button>

</body>
</html>



Textarea Object Reference Textarea object