1, Feature description:
InnerHTML Sets or gets the HTML
outerhtml setting or getting an object and its contents in the beginning and end tags of an object
InnerText settings or Text
Outertext settings (including labels) or get (excluding labels) objects in the start and end tags of an object
2, example
3, the difference:
simply put, the difference between innerHTML and outerHTML, innertext and Outertext is:
1), innerHTML and outerhtml the HTML that is included in setting the object's content will be parsed, and innertext and Outertext will not.
2, when setting, innerHTML and innertext only set the text within the label, while outerHTML and Outertext set the text including the label.
Special Note:
innerHTML is an attribute that conforms to the standard of the web, and innertext only applies to IE, so use innerhtml as much as possible, and less innertext, if you want to output content that does not contain HTML tags, You can use innerHTML to get content that contains HTML tags, and then use regular expressions to remove HTML tags, and here is a simple example that meets the requirements of the international Standards of the Consortium:
<a href= "Javascript:alert (document.getElementById (' Test '). Innerhtml.replace (/<.+?>/gim, ')" > No HTML, Conforming to the </a> of the International Consortium