Document Method:
var cont = document.getelementbyidx_x (' cont ');
ClassName Adding class to tags
Cont.classname = ' Fcolor ';
The SetAttribute method can add some properties, but not CSS styles!
var a_id = document.getelementbyidx_x (' a_id ');
A_id.setattribute (' href ', ' http://www.oeeee.com ');
What is produced by getattribute
var A_att = a_id.getattribute (' href ');
document.write (' getattribute ' generated content: ' + A_att + ' <br> ' + ' <br> ');
What is produced by removeattribute
var A_att = a_id.removeattribute (' href ');
document.write (' RemoveAttribute after the content: ' + A_att + ' <br> ' + ' <br> ');
innerHTML Getting HTML content
document.write (' InnerHTML ' generated content: ' + cont.innerhtml + ' <br> ');
The Getelementsbytagname_r () method returns a collection of objects with the specified label name, not commonly used
var div = document.getelementsbytagname_r (' div ');
document.write (' Getelementbytagname () generated content: ' + div.length + ' <br> ');
Document.body returns the BODY element tag
var dom_body = document.body;
Dom_body.setattribute (' bgcolor ', ' #186376 ');
var txt = dom_body.createtextnode (' DFSDFSDJFFDSF ');
var p = dom_body.createelement_x (' P ');
P.appendchild (TXT);
Dom_body.appendchild (P);
----------------------------------------------------------------------------
- Document Method:
- getElementById (ID) node returns a reference to the specified node.
- Getelementsbytagname_r (name) NodeList returns a collection of all matching elements in the document
- createelement_x (name) node node
- createTextNode (text) node creates a plain text node
- Ownerdocument document points to the documentation that this node belongs to
- DocumentElement node returns HTML nodes
- Document.body node returns to the body nodes
- Element method:
- GetAttribute (AttributeName) String returns the value of the specified property
- SetAttribute (Attributename,value) String assigns a value to a property
- RemoveAttribute (attributename) String removes the specified property and its value
- Getelementsbytagname_r (name) NodeList returns a collection of all matching elements within a node
- Node Method:
- AppendChild (Child) node adds a new sub-node to the specified node.
- RemoveChild (Child) node removes sub-nodes of the specified node
- ReplaceChild (newchild,oldchild) node replaces the child nodes of the specified node
- InsertBefore (newchild,refchild) node inserts a new node in front of the node at the same level
- HasChildNodes () Boolean returns True if the node has a child node.
- Node Property:
- NodeName string holds the name of the node in the form of a string
- NodeType String type of node to be stored in integer data format
- NodeValue String holds the value of the node in the available format
- ParentNode node's reference to the parent node of the node point
- ChildNodes NodeList A collection of references that point to a child node
- FirstChild node refers to the first sub-node in the binding of a child node
- LastChild node refers to the last sub-node in the Union of child nodes
- PreviousSibling node points to the previous sibling; If the node is a sibling node, the value is null
- NextSibling node points to the latter sibling, and if the node is a sibling node, the value is null
JS dom most commonly used API