Textarea form Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea


The form property returns the form that contains the text area.

Return Value

A reference to the form element containing the text area. If the text area is not in a form, null is returned

The following code shows how to return the id of the form containing the text area:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<form id="myForm">
<textarea id="myTextarea" rows="4" cols="50">
new value// w  w  w  . j  av a2  s .  co  m

<button type="button" onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {
    var x = document.getElementById("myTextarea").form.id;
    document.getElementById("demo").innerHTML = x;


Related Tutorials