Firstchild. nodevalue

Source: Internet
Author: User

Suppose we already have a DOM object whose content is as follows:
Content

In JavaScript, we generally need to do this to obtain the title label and text.
VaR Title = Dom. getelementsbytagname ("title ");
Alert (title [0]. nodename); // obtain "title"
When alert (title [0]. nodevalue) is used, FF can only obtain # text, while Ie can only obtain null.
Later, I checked a lot of information. The object text type or object element is also a node.
In the above example, the title is not a simple text content, but a text node.
It also has its own nodename, but it should not be used.
Therefore, it should be written:
Alert (title [0]. firstchild. nodevalue); // obtain the "title"

On the other hand, the create_text_node method is also used to generate a text.
Append_child is also used to add it to a parent node.
It indicates that it is actually a node and requires one more firstchild

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.