NextSibling in javascript uses da trap (keng) _ javascript tips-js tutorial

Source: Internet
Author: User
Regarding the HTMLXML node, nextSibling in IE does not return text nodes, whereas chrome or firefox will return text nodes. Today, when writing JavaScript code, it encounters a da trap (keng)

Question about HTML/XML nodes

It is said that in IE, nextSibling will not return text nodes, while chrome or firefox will return text nodes ......

This is a serious problem for my work.

I found a lot of Processing Methods on the Internet and added various encapsulated functions to js ......

Later I found a nextElementSibling method ......

This will not return text nodes, No matter what browser ......

Really pitfall

Similarly, fistChild has a corresponding firstElementChild. Other functions that select nodes should also have corresponding Element methods, but they have not tried ......

Then I suddenly found a fistChildElement ()...... I guess this is from c ++ ......
Related Article

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.