value
收藏:0
阅读:20
Textarea value 属性
定义和用法
value 属性设置或返回 textarea 的文本。
语法
设置 value 属性:
textareaObject.value="text"
返回 value 属性:
textareaObject.value
值 | 描述 |
---|---|
text | 指定文本框的内容 |
浏览器支持
所有主流浏览器都支持 value 属性
实例
弹出 textarea 元素的文本:
<html>
<head>
<script>
function displayResult()
{
alert(document.getElementById("myTextarea").value);
}
</script>
</head>
<body>
<textarea id="myTextarea" cols="20">
At dongcoder you will find all the Web-building tutorials you need, from basic HTML to advanced XML, SQL, ASP, and PHP.
</textarea>
<br>
<button type="button" onclick="displayResult()">Alert value of text area</button>
</body>
</html>
<head>
<script>
function displayResult()
{
alert(document.getElementById("myTextarea").value);
}
</script>
</head>
<body>
<textarea id="myTextarea" cols="20">
At dongcoder you will find all the Web-building tutorials you need, from basic HTML to advanced XML, SQL, ASP, and PHP.
</textarea>
<br>
<button type="button" onclick="displayResult()">Alert value of text area</button>
</body>
</html>