form
Textarea form 属性
定义和用法
form 属性返回对包含该 text area 的 表单的引用。
若成功,则该属性返回一个 form 对象。
语法
textareaObject.form
浏览器支持
所有主流浏览器都支持 form 属性
实例
本例返回文本域所属的表单的 id:
<html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("myTextarea").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
<textarea id="myTextarea" cols="20">
At jiaocheng.bubufx.com you will find all the Web-building tutorials you need, from basic HTML to advanced XML, SQL, ASP, and PHP.
</textarea>
</form>
<br>
<button type="button" onclick="displayResult()">Show id of container form</button>
</body>
</html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("myTextarea").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
<textarea id="myTextarea" cols="20">
At jiaocheng.bubufx.com you will find all the Web-building tutorials you need, from basic HTML to advanced XML, SQL, ASP, and PHP.
</textarea>
</form>
<br>
<button type="button" onclick="displayResult()">Show id of container form</button>
</body>
</html>