I. Finding elements
1.document.getelementbyid ("id"); Search by ID, find at most one.
var A=document.getelementbyid ("id"), put the found element in variable a.
2.getElementsByClassName () According to the class, find out the array.
3.getElementsByName () According to name, find out the array.
4.getElementsByTagName () based on the tag name, find out the array.
Two. Operation Contents
1. Non-form elements: for example var D=document.getelementsbyid ("a");
1. Get text: D.innertext only take the text inside!
2. Set the text: D.innertext=hello; The text inside will turn into hello.
3. Get HTML code: d.innerhtml gets all the tags and text that are set inside the D element!
4. Set HTML code:d.innerhtml=<b> bold text </b>.
2. Form elements
The value of the form element is
1. Assignment: D.value= "Assignment";
2. Get the value: Alert (d.value);
Three. Operation Properties
This is not a property, it is Method 1
1. Add attribute: D.setattribute ("attribute name", "Value of attribute");
2. Get Properties: D.getattribute ("attribute name");
3. Remove attribute: D.removeattribute ("attribute name");
Four. Operation Style
Get the style in JS only get inline!
1.d.style. Follow the style that you want to manipulate in the style.
Five. Common events
Add return or FALSE to block the default action
OnClick: mouse click Trigger
OnDblClick: Double-click Trigger
Onmouserover: Trigger above mouse
Onmouserout: Mouse move out Trigger
Onmousermov: Mouse on top move is trigger
OnChange: As long as the content change is triggered
Onblur: triggers when losing focus
Onfocus: Triggers when focus is acquired
OnKeyDown: Triggered when the button is pressed
OnKeyUp: Triggered when the button is lifted
onkeypress: Event is triggered when the user presses and releases any alphanumeric keys.
JS basic Window.document object operation and Common events!