The HTML in between but not including the tags that define the element is extracted. The resulting content complete with tags and text is returned when this property is being read.
When the property is being written to, the start and end tags remain intact but everything between them is replaced with a sequence of HTML content.
This property contains the text and any HTML tags that are contained in the body of the element. If you only want the text, then use the innerText property.
If you want to include the containing tags, then use the outerHTML or outerText properties instead.
You can assign new text to be displayed in the HTML element by using this property as an LValue.
The innerHTML property of an HTML Element object is supported in Netscape 6.0 although it is not mandated in the DOM specification. However Netscape 6.0 does not also support innerText, outerHTML or outerText. You should be able to accomplish what you need with innerHTML though.
Be careful if you extract the innerHTML of an element and document.write() it back to the same document. You can create recursive loop situations if you are evaluating in global code during the document loading process.
You cannot set this property while the document is loading.
MSIE version 4 for Macintosh does not support this as widely as the Windows version or later versions of MSIE for Macintosh.
Prev | Home | Next |
Element.id | Up | Element.innerText |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |