Home >Web Front-end >JS Tutorial >NextSibling in javascript uses trap (keng)_javascript skills

NextSibling in javascript uses trap (keng)_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:50:041031browse

I encountered a trap (keng) when writing js today

About HTML/XML nodes

It is said that nextSibling will not return text nodes in IE, but Chrome or Firefox will return text nodes...

This has brought about very serious problems in my work

I found many processing methods on the Internet, all of which add various packages to js Function...

Later I found out that there is a nextElementSibling method...

This will not return text nodes, no matter what browser it is...

What a big pitfall

Similarly, there is a corresponding firstElementChild for fistChild. Other functions that select nodes should also have corresponding Element methods, but I haven’t tried it yet...

Then I suddenly found fistChildElement()... ⊙﹏⊙bhan, I guess this is in c …

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn