The Dom\Element class
(PHP 8 >= 8.4.0)
类摘要
属性
namespaceURIThe namespace URI of the element.
prefixThe namespace prefix of the element.
localNameThe local name of the element.
tagNameThe HTML-uppercased qualified name of the element.
classNameA string representing the classes of the element separated by spaces.
classListReturns an instance of Dom\TokenList to easily manage the classes on this element.
attributesReturns an instance of Dom\NamedNodeMap that represents the attributes of this element.
idReflects the element ID through the "id" attribute.
First child element or null.
Last child element or null.
The number of child elements.
previousElementSiblingThe previous sibling element or null.
The next sibling element or null.
A Dom\HTMLCollection containing all child elements of this node. Available as of PHP 8.5.0.
innerHTMLThe inner HTML (or XML for XML documents) of the element.
outerHTMLThe outer HTML (or XML for XML documents) of the element, including the element itself. Available as of PHP 8.5.0.
substitutedNodeValueThe node value with entity substitution enabled.
更新日志
| 版本 | 说明 |
|---|---|
| 8.5.0 | Added the Dom\Element::getElementsByClassName() and Dom\Element::insertAdjacentHTML() methods. |
注释
注意:
此 DOM 扩展在处理方法或属性时使用 UTF-8 编码。 解析器方法会自动检测编码,或允许调用者指定编码。
目录
- Dom\Element::getElementsByClassName — Returns a collection of descendant elements that have the given classes
- Dom\Element::insertAdjacentHTML — Parses a string as HTML or XML and inserts the result at a given position
来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。
