CARVIEW |
Select Language
HTTP/2 301
server: GitHub.com
content-type: text/html
x-origin-cache: HIT
location: https://webplatform.github.io/docs/dom/HTMLTextAreaElement/value/
access-control-allow-origin: *
expires: Wed, 15 Oct 2025 23:10:46 GMT
cache-control: max-age=600
x-proxy-cache: MISS
x-github-request-id: D454:1AF2E3:6F01:A87C:68F0279A
accept-ranges: bytes
age: 0
date: Wed, 15 Oct 2025 23:00:46 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210027-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1760569246.300824,VS0,VE284
vary: Accept-Encoding
x-fastly-request-id: 69bd02a0319e0d37dc03817b9c4a2f878c81957c
content-length: 162
HTTP/2 200
server: GitHub.com
content-type: text/html; charset=utf-8
last-modified: Thu, 09 Jan 2020 08:57:10 GMT
access-control-allow-origin: *
etag: W/"5e16eae6-2e73"
expires: Wed, 15 Oct 2025 23:10:46 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: 4007:451DA:6F39:A839:68F02792
accept-ranges: bytes
age: 0
date: Wed, 15 Oct 2025 23:00:46 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210027-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1760569247.598432,VS0,VE303
vary: Accept-Encoding
x-fastly-request-id: 5cb8cefb4fe18e69f6670fd0ebc3a4f021e9f36f
content-length: 3070
value ยท WebPlatform Docs
This page is Almost Ready
Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.
value
Summary
Gets the content of a <textarea> element.
Property of dom/HTMLTextAreaElementdom/HTMLTextAreaElement
Syntax
var textAreaContent = textAreaElement.value;
textAreaElement.value = newTextAreaContent;
Return Value
Returns an object of type StringString
The content of the element, whether entered, existing or otherwise visible.
Examples
The following code uses this property to log the content of a <textarea>
and its length.
// Declaring the used variables first.
var textAreaList, textArea;
// Getting any <textarea> in the page
textAreaList = document.getElementsByTagName("textarea");
// Verifying there is at least one.
if (textAreaList.length) {
// Getting the first <textarea> in the page.
textArea = textAreaList[0];
// Logging the content of the first <textarea> in the page.
console.log("The content of the first textarea element is - " +
textArea.value);
// Logging the codepoint length of the
// content of the first <textarea> in the page.
console.log("The codepoint length of the content of the first textarea element is - " +
textArea.value.length);
}
Usage
Use this property to get the content of <textarea>.
Notes
In JavaScript/ECMAScript, the length property of this property can be used to determine the codepoint length of the content.
Related specifications
- Document Object Model (DOM) Level 1
- W3C Recommendation
- Document Object Model (DOM) Level 2 HTML
- W3C Recommendation
- W3C HTML5
- W3C Candidate Recommendation
- WHATWG HTML
- Living Standard
See also
Related articles
HTML
value