js dom operation summary

The DOM + BOM + ES 
1 the DOM Document Object Model Object Model the Document
dom tree

HTML
|
head body
| |
Meta title div
2 events ----- behavior of
the three elements of the type of event (what specific behavior), the event source (who happened to this behavior ), the event handler

js program how to handle events
event source. event = event handler

DOM
elements operating
create elements
1 document.write () (generally not)
2 the innerHTML
3 document.createElement
adding elements
appendChild ()
the append () (there are compatibility issues )
insertBefore ()
to remove elements
removeChild () (known parent element) / remove () (suicide)
modify elements
modify the properties of
.src / .href / .title / ... (standard attributes)

setAttribute () / getAttribute () / removeAttribute () ( Standard properties and custom properties may operate)
DataSet custom property may be disposed on the html tag data- * manner, using JavaScript or custom attributes, read when an object is through the dataset, the "." to get the property
modification element content
innerHTML (support tab) / innerText (does not support tags)
to modify form elements
value / type / disabled / checked / ...
modify elements of the style
style. ** *
className
find elements
. 1 API

2 H5 new API

. 3 relation attribute
the parentNode
Children
previousElementSibling (text element)
nextElementSibling (text element)
event operation
event source. = event handler event
the onclick
the onmouseover / onmouseout
the onfocus / the onblur
onMouseDown
...

Guess you like

Origin www.cnblogs.com/lyt0207/p/11919226.html