Obtain basic knowledge of parent tag _

Source: Internet
Author: User
Obtain the parent tag
No event under FF
Use arguments [0]

No srcElement under FF
Target

No parentElement under FF
Use parentNode

The Code is as follows:


Function obj_event_onsomething (e ){
Var e = window. event? Window. event: e;
Var srcEle = e. srcElement? E. srcElement: e.tar get;
Var theObjectYouWant = srcEle. parentNode;
}


I just found that the childNodes in FF is 1 larger than that in IE.

The Code is as follows:

O. previussibling. href | o. previousSibling. previousSibling. href
The first expression is used for IE, and the other one is used for FireFox.
In IE, XMLDom does not have the preserveWhiteSpace attribute. That is, blank space is treated as a node, while in IE, the default value is false, that is, blank space is not considered as a node.

XMLDom seems unrelated to the above mentioned, but in FireFox, previussibling is blank unless there is no space between two HTML tags.


This blank refers to # text node

The Code is as follows:


123
6546
321



Here, p should have five subnodes.
1. The carriage return line between p and
2. a mark
3. \ r \ n6546 \ r \ n
4. B mark
5. The carriage return line between Mark B and end p
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.