DOM 学习笔记一
获取元素
-
getElementById
-
getElementsByClassName
-
getElementsByTagName
-
getElementsByName
-
querySelector
-
querySelectorAll
父节点
-
parentElement
-
parentNode
子节点
-
children
-
childNodes
-
firstChild
-
lastChild
-
firstElementChild
-
lastElementChild
兄弟节点
-
nextSibling
-
previousSibling
-
nextElementSibling
-
previousElementSibling
节点创建
-
createElement
-
createTextNode
-
createDocumentFragment
DOM 更改
-
appendChild
-
removeChild
-
replaceChild
-
insertBefore
属性
-
getAttribute
-
setAttribute
-
hasAttribute
-
removeAttribute
高度与宽度
-
offsetTop
-
getBoundingClientRect
-
clientHeight
-
offsetHeight
-
clientHeight
-
clientWidth
-
offsetHeight
-
offsetWidth
-
scrollHeight
-
scrollTop
-
innerHeigh
-
innerWidth
其他有用的属性与方法
-
traget
-
currentTarget
-
preventDefault
如何获取一个div标签的所有同级(兄弟)标签?
https://gomakethings.com/how-to-get-an-elements-siblings-with-vanilla-javascript/