-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
41 lines (28 loc) · 1013 Bytes
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---
title: "Node: lastChild property"
short-title: lastChild
slug: Web/API/Node/lastChild
page-type: web-api-instance-property
browser-compat: api.Node.lastChild
---
{{APIRef("DOM")}}
The read-only **`lastChild`** property of the {{domxref("Node")}} interface
returns the last child of the node, or `null` if there are no child nodes.
> **Note:** This property returns any type of node that is the last child of this one.
> It may be a {{domxref("Text")}} or a {{domxref("Comment")}} node.
> If you want to get the last {{domxref("Element")}} that is a child of another element,
> consider using {{domxref("Element.lastElementChild")}}.
## Value
A {{domxref("Node")}} that is the last child of the node, or `null` if there are no child nodes.
## Example
```js
const tr = document.getElementById("row1");
const corner_td = tr.lastChild;
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("Node.firstChild")}}
- {{domxref("Element.lastElementChild")}}