💾node.isInPage
💾 replit: node.isInPage
// 🔸 node.isInPage
Object.defineProperty(Node.prototype, 'isInPage', {
get() { return document.body.contains(this) }
});不管一個 HTMLElement 是 display:none、visibility:hidden、opacity:0 等等,只要它在 DOM 裡面,node.isInPage 就是 true。
CSS/JS/HTML visible space clickable
---------------------------------------------------
CSS opacity: 0 ❌ ✅ ✅
CSS visibility: hidden ❌ ✅ ❌
CSS display: none ❌ ❌ ❌
JS .hidden = false ❌ ❌ ❌
HTML <... hidden> ❌ ❌ ❌Node ⟩ .contains() - check if a node is a descendant of a given node. (itself included)
HTMLElement ⟩ .hidden - quite different from using CSS
display.
問:「HTML hidden attribute is equivalent to HTMLElement.hidden property❓」
Last updated
Was this helpful?