name
Textarea name 属性
定义和用法
name 属性设置或返回 textarea 的名称。
语法
设置 name 属性:
textareaObject.name="text"
返回 name 属性:
textareaObject.name
提示:name 属性没有默认值。
值 | 描述 |
---|---|
text | 指定的textarea的名称 |
浏览器支持
所有主流浏览器都支持 name 属性
实例
本例设置 textarea 的名称:
<html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("myTextarea").name;
alert(x);
}
</script>
</head>
<body>
<textarea id="myTextarea" name="txt1" cols="20">
At bubufx 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()">Show name of text area</button>
</body>
</html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("myTextarea").name;
alert(x);
}
</script>
</head>
<body>
<textarea id="myTextarea" name="txt1" cols="20">
At bubufx 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()">Show name of text area</button>
</body>
</html>