Node:lastChild 属性
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Node
接口的 lastChild
只读属性返回节点的最后一个子节点,如果没有子节点,则返回 null
。
备注:
此属性返回作为此节点最后一个子节点的任何类型的节点。它可能是 Text
或 Comment
节点。如果你要获取另一个元素的最后一个 Element
子元素,可以考虑使用 Element.lastElementChild
。
值
作为节点最后一个子节点的 Node
,如果没有子节点,则为 null
。
示例
js
const tr = document.getElementById("row1");
const corner_td = tr.lastChild;
规范
Specification |
---|
DOM # ref-for-dom-node-lastchild① |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
lastChild |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.