Table Format .html
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml">
Domutil. js
(This JS is made up of class notes, and some code is not used this time)
VaR customfunctions = {// get the set of sub-nodes (General for IE and ff) getchildnodes: function (node) {var arr = []; var nodes = node. childnodes; For (var I in nodes) {If (nodes [I]. nodetype = 1) {// search for the element node arr. push (nodes [I]) ;}} return arr ;}, // get the first element subnode (ie, FF General) getfirstelementchild: function (node) {return node. firstelementchild? Node. firstelementchild: node. firstchild;}, // get the last element sub-node (ie, FF General) getlastelementchild: function (node) {return node. lastelementchild? Node. lastelementchild: node. lastchild;}, // obtain the previous adjacent node (ie, FF General) getpreviussibling: function (node) {// return the node after finding the previous node, if the node is not found, the nulldc {node = node is returned. previussibling;} while (node & node. nodetype! = 1) return node;}, // obtain the next adjacent node (ie, FF General) getnextsibling: function (node) {// return the node after finding the next node, if the node is not found, the nulldc {node = node is returned. nextsibling;} while (node & node. nodetype! = 1) return node;}, // Insert the element to the end of the specified node. insertafter: function (newnode, targetnode) {If (newnode & targetnode) {var parent = targetnode. parentnode; var nextnode = This. getnextsibling (targetnode); If (nextnode & parent) {parent. insertbefore (newnode, nextnode);} else {parent. appendchild (newnode) ;}}};/* clear spaces before and after the string */string. prototype. trim = function () {return this. replace (/^ \ s * | \ s * $/, "") ;};/* search element: $ q ("Div"): bytagname $ q (". L "): byclassname $ q (" # l "): byid $ q (" $ name "): bynameselector: parentelement: parent element */window. $ q = function (selector, parentelement) {If (selector & (typeof selector) = 'string') {selector = selector. trim (); // remove the leading and trailing spaces var parentel = parentelement | document; var nodearr = new array (); var firstchar = selector. substr (); // obtain the first character. // It starts with #, indicating that if (firstchar = '#') {return parentel. getelementbyid (selector. substr (1);} // search for else if (firstchar = '$') {var all = parentel according to the name starting with $. getelementsbytagname ("*"); For (VAR I = 0; I <all. length; I ++) {var name = All [I]. getattribute ("name"); If (name = selector. substr (1) {nodearr. push (ALL [I]) ;}} Delete I; return nodearr ;}// use. start with else if (firstchar = '. ') {var classname = selector. substr (1); If (parentel. getelementsbyclassname) {return parentel. getelementsbyclassname (classname);} else {var childlist = parentel. getelementsbytagname ("*"); For (VAR I = 0; I <childlist. length; I ++) {var nodeclassname = childlist [I]. classname; var classnamearr = nodeclassname. split (''); For (var j = 0; j <classnamearr. length; j ++) {If (classnamearr [J] === classname) {nodearr. push (childlist [I]) ;}} Delete J ;}delete I; return nodearr ;}// otherwise, query else {return parentel Based on the tag name. getelementsbytagname (selector) ;}} else {return document. all | document. getelementsbytagname ("*");}};