Sets or retrieves the text between the start and end tags of the object.
Syntax
HTML N/A Scripting object.innerText [ = sTxt ]
Possible Values
sTxt String that specifies the text between the start and end tags. The property is read/write with no default value (see Remarks).
Remarks
The innerText property is read-only on the HTML, TABLE, TBODY, TFOOT, THEAD, and TR objects.
When the innerText property is set, the given string completely replaces the existing content of the object.
You can set this property only after the onload event fires on the window. When dynamically creating a tag using TextRange, innerHTML, or outerHTML, use Microsoft® JScript® (compatible with ECMA 262 language specification) to create new events to handle the newly formed tags. Microsoft® Visual Basic® Scripting Edition (VBScript) is not supported.
You can change the value of the TITLE element using the document.title property.
To change the contents of the TABLE, TFOOT, THEAD, and TR elements, use the table object model. For example, use the rowIndex property or the rows collection to retrieve a reference to a specific table row. You can add or delete rows using the insertRow and deleteRow methods. To retrieve a reference to a specific cell, use the cellIndex property or the cells collection. You can add or delete rows using the insertCell and deleteCell methods. To change the content of a particular cell, use the innerHTML property.
Example
This example uses the innerText property to replace an object's contents. The object surrounding the text is not replaced.
Sample Code
<P ID=oPara>Here's the text that will change.</P> : <BUTTON onclick="oPara.innerText='WOW! It changed!'">Change text</BUTTON> <BUTTON onclick="oPara.innerText='And back again'">Reset</BUTTON>
Applies To
A, ACRONYM, ADDRESS, B, BDO, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, custom, DD, DEL, DFN, DIR, EM, FIELDSET, FONT, FORM, HEAD, Hn, HTML, I, IFRAME, INS, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, NEXTID, NOBR, OL, OPTION, P, PLAINTEXT, PRE, Q, RT, RUBY, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, STYLE, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, XMP, XMP
See Also