Latest web development tutorials

HTML DOM Textarea name attribute

Textarea Object Reference Textarea object

Definition and Usage

name property sets or returns the name of the textarea.

grammar

Setting name attribute:

textareaObject.name="text"

Returns the name attribute:

textareaObject.name

Tip: name property has no default value.

描述
text 指定的textarea的名称


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support attribute name


Examples

Examples

This example sets the textarea name:

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

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

<button type="button" onclick="displayResult()">显示 textarea name 属性值</button>

</body>
</html>



Textarea Object Reference Textarea object