blob: 3f31c8f722cb9f8ff4cf2c1d4a4e4fd982f4d546 (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
---
title: element.lastChild
slug: Web/API/Node/lastChild
tags:
- API
- DOM
- Enfant
- Noeuds
- Propriétés
translation_of: Web/API/Node/lastChild
---
<p>{{APIRef("DOM")}}</p>
<p>La propriété en lecture seule<strong> </strong><code><strong>Node.lastChild</strong></code> renvoie le dernier enfant du noeud. Si son parent est un élément, l'enfant est généralement un noeud élément, texte ou commentaire. Elle renvoie <code>null</code> s'il n'y a aucun enfant.</p>
<h2 id="Syntaxe" name="Syntaxe">Syntaxe</h2>
<pre class="syntaxbox">var <var>childNode</var> = <var>node</var>.lastChild;
</pre>
<p> </p>
<h2 id="Exemple" name="Exemple">Exemple</h2>
<p> </p>
<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">var</span> tr <span class="operator token">=</span> document<span class="punctuation token">.</span><span class="function token">getElementById</span><span class="punctuation token">(</span><span class="string token">"row1"</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="keyword token">var</span> corner_td <span class="operator token">=</span> tr<span class="punctuation token">.</span>lastChild<span class="punctuation token">;</span></code></pre>
<h2 id="Spécification">Spécification</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Spécification</th>
<th scope="col">Statut</th>
<th scope="col">Commentaire</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('DOM WHATWG', '#dom-node-lastchild', 'Node.lastChild')}}</td>
<td>{{Spec2('DOM WHATWG')}}</td>
<td>Pas de changement</td>
</tr>
<tr>
<td>{{SpecName('DOM3 Core', 'core.html#ID-61AD09FB', 'Node.lastChild')}}</td>
<td>{{Spec2('DOM3 Core')}}</td>
<td>Pas de changement</td>
</tr>
<tr>
<td>{{SpecName('DOM2 Core', 'core.html#ID-61AD09FB', 'Node.lastChild')}}</td>
<td>{{Spec2('DOM2 Core')}}</td>
<td>Pas de changement</td>
</tr>
<tr>
<td>{{SpecName('DOM1', 'level-one-core.html#ID-61AD09FB', 'Node.lastChild')}}</td>
<td>{{Spec2('DOM1')}}</td>
<td>Définition initiale</td>
</tr>
</tbody>
</table>
<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
<p>{{Compat("api.Node.lastChild")}}</p>
<div id="compat-desktop"> </div>
|