• ARعربي
  • ENEnglish
  • ESEspañol
  • FAفارسی
  • FRFrançais
  • IDIndonesia
  • ITItaliano
  • JA日本語
  • KO한국어
  • RUРусский
  • TRTürkçe
  • UKУкраїнська
  • ZH简体中文

ما قصد داریم این پروژهٔ متن‌باز را در دسترس همهٔ مردم در سرتاسر دنیا قرار دهیم.

به ترجمهٔ محتوای این آموزش به زبان خودتان کمک کنید/a>.

    نقشه آموزش
    اشتراک گذاری
    • آموزش
    • مرورگر: Document، Eventها، رابط‌ها
    • Document
    • Walking the DOM
    بازگشت به درس
    این محتوا تنها در این زبان‌ها موجود است: عربي, English, Español, Français, Italiano, 日本語, 한국어, Русский, Türkçe, Українська, 简体中文. لطفاً به ما

    The sibling question

    اهمیت: 5

    If elem – is an arbitrary DOM element node…

    • Is it true that elem.lastChild.nextSibling is always null?
    • Is it true that elem.children[0].previousSibling is always null ?
    1. Yes, true. The element elem.lastChild is always the last one, it has no nextSibling.
    2. No, wrong, because elem.children[0] is the first child among elements. But there may exist non-element nodes before it. So previousSibling may be a text node.

    Please note: for both cases if there are no children, then there will be an error.

    If there are no children, elem.lastChild is null, so we can’t access elem.lastChild.nextSibling. And the collection elem.children is empty (like an empty array []).

    • © 2007—2025  Ilya Kantor
    • دربارهٔ پروژه
    • تماس با ما