DOM (Document Object model), language independent, is used to manipulate XML (in the Web) and HTML (in the browser) of the application interface of the document. The more times you access the DOM, the slower it is and the higher the cost.
InnerHTML Properties: Ducument.getelementbyid (' here '). InnerHTML ()
Categorization malleability Dom method: Ducument.createelement (), ducument. createTextNode ()
Node clone: Ducument.clonenode ()
Get collection: Ducument.getelementbyname ()
Ducument.getelementbyclassname ()
Ducument.getelementbytagname ()
This collection object is a list of similar arrays, without the push and slice methods of the array, but provides the length property in the array, using local variables when accessing the collection elements
All IMG elements in the page: ducument.images
All elements of a page: Ducument.links
All form elements on the page: ducument.forms
All fields of the first form on the page: ducument.forms[0].elements
Gets the first element: Ducument.getelementbyid (' div '). FirstChild
Get adjacent elements: Ducument.getelementbyid (' div '). firstchild.nextsibling
Gets the collection of elements: Ducument.getelementbyid (' div '). childNodes
API only returns ELEMENT nodes: child instead of childNodes
Childelementcount instead of Childnodes.length
Firstelementchild instead of FirstChild
Lastelementchild instead of LastChild
Nextelementchild instead of nextSibling
Previouselementsibling instead of previoussibling
Selector API:ducument.querySelectorAll (' #menu a ') <=> Ducument.getelementbyid (' menu '). Getelementbytagname (' a ')
Class is warning and notice elements: Ducument.queryselectorall (' div.warning, Div.notice ')
<=> var errs=[];
DIVs = doucument.getelementsbytagname (' div ');
ClassName = ";
for (var i=0; len = divs.length; i<len; i++) {
ClassName = Divs[i].classname;
if (className = = ' notice ' | | className = = ' Warning ') {
Errs.push (Divs[i]);
}
}
Dom Programming for JavaScript