Click to return to the DHTML, HTML     
outerHTML Property     overflow Attribute | over...     DHTML Properties    
Web Workshop  |  DHTML, HTML & CSS

outerText Property


Sets or retrieves the text of the object.

Syntax

HTMLN/A
Scriptingobject.outerText [ = sTxt ]

Possible Values

sTxtString that specifies the text.

The property is read/write with no default value (see Remarks).

Remarks

The outerText property is read-only on the HTML, TBODY, TD, TFOOT, TH, THEAD, and TR objects.

When this property is set, the given string completely replaces the original text in 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 TFOOT, THEAD, TR, and TD 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 outerText property to replace an object's content; the object itself also is replaced.

Sample Code

<DIV ID=oDiv>
<P ID=oPara>Here's the text that will change.</P>
</DIV>
:
<BUTTON onclick="oPara.outerText='WOW! 
    It changed!'">Change text</BUTTON>
<BUTTON onclick="oDiv.innerHTML='<P ID=oPara>
    And back again</P>'">Reset</BUTTON>

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
A, ACRONYM, ADDRESS, APPLET, AREA, B, BDO, BGSOUND, BIG, BLOCKQUOTE, BR, BUTTON, CENTER, CITE, CODE, COMMENT, custom, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, HEAD, Hn, HR, HTML, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, NEXTID, NOBR, OBJECT, OL, P, PLAINTEXT, PRE, Q, RT, RUBY, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, WBR, XMP

See Also

insertAdjacentText



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.