Movatterモバイル変換


[0]ホーム

URL:


  1. 開発者向けのウェブ技術
  2. Web API
  3. Element
  4. lastElementChild

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。

View in EnglishAlways switch to English

Element: lastElementChild プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

Element.lastElementChild は読み取り専用のプロパティで、要素の最後の子をElement で返します。子要素がない場合はnull を返します。

Element.lastElementChild は要素ノードのみを含みます。テキストやコメントノードなど、要素以外のノードを含むすべての子ノードを取得するには、Node.lastChild を使用してください。

Element オブジェクト、またはnull です。

html
<ul>  <li>First (1)</li>  <li>Second (2)</li>  <li>Third (3)</li></ul><script>  const list = document.getElementById("list");  console.log(list.lastElementChild.textContent);  // logs "Third (3)"</script>

仕様書

Specification
DOM
# ref-for-dom-parentnode-lastelementchild①

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp