DOM Add, delete, change, check Oul.children get UL sub-nodes property with length oul.children[0] get UL 1th child node use more oul.children[ oul.children.length-1] Get UL's last sub-node Use more oUl.parentNode get UL parent node & nbsp body,html,document oul.firstelementchild| | oul.firstchild First node "FirstChild low version ie6-8firstelementchild advanced Browser" oul.lastelementchild| | oul.lastchild Last word node Ditto oli.previouselementsibling| | oli.previoussibling Get previous sibling node relative Oli.nextelementsibling| | oli.nextsibling Get next sibling node relative to yourself var oli=document.createelement (' li '); Create an Li node Create an Assignment add 3 steps oli.innerhtml= ' assign it oul.appendchild (oLi); INSERT into Oul (insert backwards) common oul.insertbefore (where to plug in) INSERT into front of an element &nbsP;oul.removechild (the element to remove); Delete an element node. CloneNode () Cloning an element CloneNode (true) deep clone Remove ID: node. removeattribute (' id '); " window.onscroll Scrolling Events window.onresize window events when the mouse is scrolling when the window shrinks/ Zoom in Scroll distance Match scrolling event var scrolltop=document.documentelement.scrolltop| | document.body.scrolltop document.documentelement.clientheight Visible area height document.documentelement.clientwidth Viewport width offsetheight (placeholder) (live event) Object box Model height border+padding+heightoffsetwidth (placeholder) (live event) Object box model width border+padding +width offsetparent Locate parent If no parent is located bodyparentnode Structure parent offsettop ( Placeholder objects) Object box model the top value of the parent is located at the outermost distance If no parent is located, it is relative bodyoffsetleft (placeholder object) Object box model outermost distance position parent's left value relative Body getattribute (' property ') Get inline custom property if no parent is located setattribute (' attribute ', ' property value '); Set inline property values corresponding use of removeattribute (' properties ') remove attributes nbsp
Summary of DOM operations and compatibility issues inside JavaScript