DOM operations on elements: create, add, delete, modify, check, attribute operations, and event operations.
1. Create
- document.write
- innerHTML
- createElement
2. Increase
- appendChild
- insertBefore
3. Delete
- removeChild
4. Change
- Modify element attributes: src, href, title, etc.
- Modify the content of common elements: innerHTML, innerText
- Modify form elements: value, type, disabled, etc.
- Modify element style: style, className
5. Check
- API methods provided by DOM: getElementsById, getElementsByTagName
- New methods provided by H5 (recommended): querySelector, querySlectorall
- Use node operations to get elements: parent parentNode, child children, brother previousElementSibling, nextElementSibling.
6. Attribute operations
- setAttribute: set the attribute value of dom
- getAttribute: get the attribute value of dom
- removeAttribute: remove attribute
7. Event operation
- onclick: click
- onmouseover: put on top
- onmouseout: leave
- onfocus: focus
- onblur: Loss of focus
- onmousemove: mobile
- onmouseup: bounce
- onmousedown: press down