Open ajhsu opened 6 years ago
(R) = Read-only property (E) = Experimental API
.addEventListener()
.removeEventListener()
.dispatchEvent()
.nodeName
(R).nodeType
(R).nodeValue
.textContent
.parentNode
(R).parentElement
(R).ownerDocument
(R).childNodes
(R).firstChild
(R).lastChild
(R).previousSibling
(R).nextSibling
(R).cloneNode()
.normalize()
.insertBefore()
.appendChild()
.removeChild()
.replaceChild()
.contains()
.hasChildNodes()
.isEqualNode()
.isSameNode()
.compareDocumentPosition()
.tagName
(R).localName
(R).id
.attributes
(R).classList
(R).className
.innerHTML
.outerHTML
.shadowRoot
.clientLeft
(R).clientTop
(R).clientWidth
(R).clientHeight
(R).scrollLeft
.scrollTop
.scrollWidth
(R).scrollHeight
(R).hasAttribute()
.hasAttributes()
.getAttributes()
.getAttributeNames()
.setAttribute()
.removeAttribute()
.getClientRect()
.getBoundingClientRect()
.querySelector()
.querySelectorAll()
.getElementsByTagName()
.matches()
.remove()
(E).scrollIntoView()
.insertAdjacentElement()
(E).insertAdjacentHTML()
(E).insertAdjacentText()
(E).title
.tabIndex
.contextMenu
.dataset
.style
.lang
.hidden
.offsetWidth
(R)(E).offsetHeight
(R)(E).offsetLeft
(R)(E).offsetTop
(R)(E).click()
.blur()
.focus()
.doctype
(R).domain
.contentType
(R)(E).lastModified
(R).cookie
.location
(R).referrer
(R).title
.URL
(R).head
(R).body
.designMode
.anchors
.images
(R).links
(R).scripts
(R).plugins
(R).readyState
(R).documentElement
(R)太多了,常見的頁面事件註冊都在這
.createDocumentFragment()
.createElement()
.createTextNode()
.createTreeWalker()
.querySelector()
.querySelectorAll()
.getElementsByClassName()
.getElementsByTagName()
.importNode()
.open()
.close()
.write()
Table of Content
The document was migrated and re-organized from thegitfather's gist.
Accessing Dom Elements
Grab Children/Parent Node(s)
Create New DOM Elements
Add Elements to the DOM
Add Elements to the DOM cont.
Suppose you have the following HTML:
You can insert another snippet of HTML between #box1 and #box2:
Add/Remove/Toggle/Check Classes