DOM core summary

![(https://img-blog.csdnimg.cn/20200720200029126.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NzA2NzI0OA==,size_16,color_FFFFFF,t_70)

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

Guess you like

Origin blog.csdn.net/weixin_47067248/article/details/107471935