Last updated 1 year ago
browser โฉ DOM โฉ type โฉ Node
instance properties
parentNode (Node | null)
parentElement (Element | null)
childNodes (NodeList) - live NodeList include elements, text and comments.
firstChild (Node | null)
lastChild (Node | null)
nextSibling (Node | null)
previousSibling (Node | null)
nodeType (Integer) - Element (1), Text (3), Comment (8), Document (9).
nodeValue (String | null) - textual content of a node.
nodeName (String) - = Element.tagName if it's an HTML element.
$(), $all()
NodeList
Element - subclass.
MDN โฉ EventTarget โฉ Node
Filter or map nodelists in ES6
Node โฉ .textContent - gets the content of all elements, including <script> and <style> elements. (prevent XSS attacks)
<script>
<style>
Element โฉ .innerHTML - returns HTML.
HTMLElement โฉ .innerText - innerText takes CSS styles into account.
innerText
ๅ็ซฏ็ญ่จ โฉ innerTextใinnerHTMLใtextContentใouterHTML ็ๅทฎๅฅ
codepen โฉ node.textContent vs. htmlElement.innerText