First,Window.document object
1. Find element:
Docunment.getelementbyid ("id"); Search by ID, up to one;
var a =docunment.getelementbyid ("id"); The found element is placed in a variable;
Docunment.getelementsbyname ("name"); Search by name, find the array;
Docunment.getelementsbytagname ("name"); Based on the name of the tag, find out the array;
Docunment.getelementsbyclassname ("name") according to ClassName, find out the array;
2. Get content
(1) Non-form elements:
a.innerhtml, the HTML code and text in the tag are all retrieved, all the contents of the tag.
A.innertext; take only the words inside
a.outerhtml; including the contents of the label itself
(2) Form elements
var t = document.f1.t1; The form ID of the form is F1 with ID T1 input;
var t = document.getElementById ("id"); Get directly with ID.
knowledge Point:<a href= "http://www.baidu.com" onclick = "return false"> turn to Baidu </a>; add return Flase will not jump, the default is return true will jump. The button is the same, if the button is set to return flase will not commit, this can be used to control the commit jump.
3 Action Properties
First, the element is found with the ID of the element, stored in a variable: var a = document.getElementById ("id");
You can then manipulate the attributes of the element:
A.setattribute ("attribute name", "attribute value"); Set a property, add or change all can;
A.getattribute ("attribute name"); Gets the value of the property;
A.removeattribute ("attribute name"); Remove an attribute.
Window.document Object