I have never carefully explored the DOM operations of these browsers before. It is necessary to summarize all these operations.
One is to stop making mistakes in the future;
The second is to avoid looking for questions in the future;
In short, it is necessary to summarize:
Function $ (a) {return document. getelementbyid (a);} // If the node in IE is an inline element (non-style setting: Display: Block), the obtained nextsibling node is a text node (excluding spaces) // eg: // <span id = "TT"> TT </span> <span> AA </span> $ ('TT '). nextsibling. nodetype = 3 // <p id = "TT"> TT </P> <p> AA </P> $ ('TT '). nextsibling. nodetype = 1 // <p id = "TT"> TT </P> mE <p> AA </P> $ ('TT '). nextsibling. nodetype = 3 // Similarly, getprev // gets the next subnode function getnext (EL) {var next = el. nextelements Ibling | El. nextsibling; If (next. nodetype! = 1) return arguments. callee (next); return next;} // obtain the function getprev (EL) {var Prev = El of the previous subnode. previuselementsibling | el. previussibling; If (prev. nodetype! = 1) return arguments. callee (prev); Return Prev;} // obtain the first node function getfirstchild (EL) {var first = el. firstelementchild | el. firstchild; If (first. nodetype! = 1) return arguments. callee (first); return first;} // obtain the last node function getlastchild (EL) {var last = el. lastelementchild | el. lastchild; If (last. nodetype! = 1) return arguments. callee (last); return last;} // obtain all the htmlelement child node functions getchildren (EL) {return el. children;} // obtain all child node functions getchildnodes (EL) {return el. childnodes ;}
That's it.
I have never carefully explored the DOM operations of these browsers before. It is necessary to summarize all these operations.
One is to stop making mistakes in the future;
The second is to avoid looking for questions in the future;
In short, it is necessary to summarize:
Function $ (a) {return document. getelementbyid (a);} // If the node in IE is an inline element (non-style setting: Display: Block), the obtained nextsibling node is a text node (excluding spaces) // eg: // <span id = "TT"> TT </span> <span> AA </span> $ ('TT '). nextsibling. nodetype = 3 // <p id = "TT"> TT </P> <p> AA </P> $ ('TT '). nextsibling. nodetype = 1 // <p id = "TT"> TT </P> mE <p> AA </P> $ ('TT '). nextsibling. nodetype = 3 // Similarly, getprev // gets the next subnode function getnext (EL) {var next = el. nextelements Ibling | El. nextsibling; If (next. nodetype! = 1) return arguments. callee (next); return next;} // obtain the function getprev (EL) {var Prev = El of the previous subnode. previuselementsibling | el. previussibling; If (prev. nodetype! = 1) return arguments. callee (prev); Return Prev;} // obtain the first node function getfirstchild (EL) {var first = el. firstelementchild | el. firstchild; If (first. nodetype! = 1) return arguments. callee (first); return first;} // obtain the last node function getlastchild (EL) {var last = el. lastelementchild | el. lastchild; If (last. nodetype! = 1) return arguments. callee (last); return last;} // obtain all the htmlelement child node functions getchildren (EL) {return el. children;} // obtain all child node functions getchildnodes (EL) {return el. childnodes ;}
That's it.