Home > Web Front-end > JS Tutorial > body text

Get parent tag_Basics

WBOY
Release: 2016-05-16 19:24:13
Original
1097 people have browsed it

Get the parent tag
FF There is no event
using arguments[0]

FF There is no srcElement
Use target

FF There is no parentElement
Use parentNode

Copy code The code is as follows:

function obj_event_onsomething(e){
var e=window. event?window.event:e;
var srcEle=e.srcElement?e.srcElement:e.target;
var theObjectYouWant=srcEle.parentNode;
}

Just now It was also found that the childNodes under FF are larger than those under IE 1
Copy the code The code is as follows:
o .previousSibling.href || o.previousSibling.previousSibling.href
The former expression is used under IE, and the latter one is used under FireFox.
Because under IE, XMLDom does not have the preserveWhiteSpace attribute, that is: put the blank space It is also treated as a node, and IE defaults to false, that is, the blank is not regarded as a node.

XMLDom is mentioned here, which seems to be irrelevant to what is mentioned above, but under FireFox, previousSibling is blank. Unless there is no space of any kind between the two HTML tags.

This white space refers to the #text node
Copy code The code is as follows:

123
6546
321


The div here should have 5 child nodes
1. From the div mark to the carriage return and line feed before the a mark
2. a mark
3. rn6546rn
4. b mark
5. Carriage return and line feed after b mark and before div end mark
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template