DOM Object (Document Object Model )
First, the core DOM
1. Core Dom actions on label Properties (attribute) (a) check (b) delete (c))
A. The label object of the operation. SetAttribute (property name, property value): Set the properties of a label
B. The label object of the operation. GetAttribute (property name): Get Tag Properties
C. The label object of the operation. RemoveAttribute (property name) Delete Label property
2. Core DOM action on tags
Create a label
Syntax:
Document.createelement (" label name ")
such as 1:var tab_obj=document.createelement ("table")
Append tag
The Parent object . AppendChild ( the Label object to append ), appends the label object to the end of the parent object
such as 2:document.body.appendchlid ("Tab_obj");(combined as 1)
The Parent object . InsertBefore (the label object to append , before which to append), the label object is appended to the front
Remove tags
Parent Object . RemoveChild (the label object to delete ), appends the label object to the end of the parent object
Two. HTML DOM
Method:
document.getElementById (attribute value of ID)
role: by ID property value to get the Label object
document.getElementsByTagName ("label name")
The parent object. getElementsByTagName ("label name")
role: Get objects by tag name
Note: A collection of arrays is returned here need to use subscript for access even if you get only one label It is also a collection of arrays
Document.getelementsbyname ( property value of name)
Description: Through the tags in the Name property value to get the element
Note: This returns an array set Hopewell need to use subscript for access Even if it gets to only one label it's also an array collection
HTML DOM actions on label Properties
Increase: the Label object to manipulate . Property name = "Value"
Delete: the Label object to manipulate . Property name = ""
Change: the Label object to manipulate . Property name = "Re-assignment"
Check: the Label object to manipulate . Property name
However, the above actions on the label properties are does not contain the class operation of the property If you want to work with the class attribute inside the tag, you must change the class to ClassName
Format:
The label object to manipulate. ClassName
Third , CSS DOM
Format:
Assignment: To manipulate the label object. Style.css Style property = "CSS property value"
Value: The label object to manipulate. STYLE.CSS Style properties
JavaScript Basic Learning 4