Javascript Reference
Categories: Element

javascript Element outerHTML

@Aug. 17, 2009, 9:41 a.m.
outerHTML Firefox/Netscape/NN n/a IE 4 Chrome/Safari/DOM n/a  

 

Read/Write  
 

Indicates the rendered text and HTML tags (i.e., all source code), including the start and end tags, of the current element. If you want only the rendered text, see outerText. For the source code that excludes the current element's tags, see innerHTML. A change to this property that includes HTML tags is rendered through the HTML parser, as if the new value were part of the original source code. You may change this property only after the document has fully loaded, and, in the process, you can even change the type of element it is or replace the element with straight text content. Changes to the outerHTML property are not reflected in the source code when you view the source in the browser. To add to existing HTML, see the insertAdjacentHTML( ) method. This property is not supported in many objects in the Macintosh version of IE 4. The W3C DOM equivalent requires extensive manipulation of node-level objects.

 
Example
 
document.getElementById("elementID").outerHTML =
    "<acronym id="quotes">NI<i>M</i>BY</acronym>";
 
Value

String that may or may not include HTML tags.

 
Default

Empty string.

Under moderation.
Sarahelani - 3 months
Under moderation.
Nikaselani - 3 months
Under moderation.
Maxwellelani - 3 months

Powered by Linode.