Javascript examples for DOM HTML Element:Textarea
The form property returns the form that contains the text area.
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:
<!DOCTYPE html> <html> <body> <form id="myForm"> <textarea id="myTextarea" rows="4" cols="50"> new value// w w w . j av a2 s . co m </textarea> </form> <button type="button" onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myTextarea").form.id; document.getElementById("demo").innerHTML = x; } </script> </body> </html>