_javascript skill of sibling node in DOM script programming

Source: Internet
Author: User
Tags mootools
Browsers other than IE are text nodes that use newline characters as content (NodeType is 3). And the element words, NodeType is 1. Here are some practical ways to find them:
Copy Code code as follows:

Lastsibling:function (node) {
var tempobj = Node.parentNode.lastChild;
while (Tempobj.nodetype!=1 && tempobj.previoussibling!=null)
{
tempobj=tempobj.previoussibling;
}
Return (tempobj.nodetype==1) Tempobj:false;
}

This is the "simple JavaScript" book Domhelp Library in the Lastsibling method of source code. With the MooTools library to achieve the same source:
Copy Code code as follows:

' Last-child ': function () {
var element = this;
while (element = element.nextsibling)) {
if (Element.nodetype = = 1) return false;
}
return true;
}

This is the Last-child () method in the Mootools 1.2.4 source code.
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.