HTML DOM Textarea form properties
Definition and Usage
form property returns the text area that contains the reference to the form.
If successful, this property returns a form object.
grammar
textareaObject.form
Browser Support
All major browsers support form properties
Examples
Examples
This example returns form text field belongs id:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult()
{
var x=document.getElementById("myTextarea").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
<textarea id="myTextarea" cols="20">
在本教程,你可以学多很多编程的基础知识,包括 HTML, XML, SQL, ASP, 和 PHP 等各种前端内容。
</textarea>
</form>
<br>
<button type="button" onclick="displayResult()">显示 form 的 id</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult()
{
var x=document.getElementById("myTextarea").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
<textarea id="myTextarea" cols="20">
在本教程,你可以学多很多编程的基础知识,包括 HTML, XML, SQL, ASP, 和 PHP 等各种前端内容。
</textarea>
</form>
<br>
<button type="button" onclick="displayResult()">显示 form 的 id</button>
</body>
</html>
Textarea object