innerHTML properties, outerhtml attributes, textcontent attributes, innertext attribute differences _javascript Tips

Source: Internet
Author: User

The innerHTML property is used to read or set the HTML code within a node.

When the outerHTML property is used to read or set the HTML code, the node itself is included.

The Textcontent property is used to read or set the text content that the node contains.

The InnerText property and the Outertext property have different values when reading the textual content of an element node. The difference is that when you set the Text property of a node, the Outertext property causes the original element node to be replaced by the text node. Note that innertext is not a standard attribute and Firefox is not supported.

1.innerText is affected by CSS, Textcontent does not have this problem. For example, if a CSS rule hides a piece of text, innertext does not return the text, and Textcontent returns.

2.innerText The returned text, will filter out spaces, line and enter, Textcontent will not

The 3.innerText property is not part of the DOM Standard, and the Firefox browser does not even deploy this property, and Textcontent is part of the DOM standard.

The above is the entire content of this article, I hope to learn more familiar with JavaScript can help.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.