Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8776131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:58:39+00:00 2026-06-13T18:58:39+00:00

Let´s say I have following code snippet: var NewNode = document.createElement(div); NewNode.appendChild(document.createTextNode(Hello World!)); document.body.appendChild(NewNode);

  • 0

Let´s say I have following code snippet:

var NewNode = document.createElement("div");

NewNode.appendChild(document.createTextNode("Hello World!"));

document.body.appendChild(NewNode);

At what lines do I actually append an element to the DOM tree?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:58:41+00:00Added an answer on June 13, 2026 at 6:58 pm

    To answer your question very specifically, you’re appending to the document DOM tree in line three. But there’s a conceptual confusion in the wording of your question.

    There’s more than one DOM tree after the first line. There’s (1) the DOM tree of the document, which you are referring to as “the” DOM tree, although that’s not strictly speaking the only one, and there’s (2) a DOM tree consisting of a single div element. At this point, these two DOM trees are not connected. After the execution of line two, the newer DOM tree has two nodes in it, not just one. And to be perfectly persnickety, immediately after createTextNode returns but before appendChild is called, there are three DOM trees. After the third line, you’re back to a single DOM tree, the one accessible through document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following Code: <div id=parent> <div id=child></div> </div> Now I
Let's say I have the following code, which I CANNOT modify var namespace =
In JavaScript let's say we have the following code var test = 'd'; if
Let's say I have the following code snippet. function test(id) { alert(id); } testChild.prototype
Let's say I have the following code: <div id=link_other> <ul> <li><a href=http://www.google.com/>google</a></li> <li> <div
Let's say I have to following code - <body> <div id=outerdiv style=border: 1px solid
Let's say I have the following code snippet: int i; double value; for(i =
Let's say i have the following code: <div class=wrapper> <div class=title></div> <div></div> </div> <div
Let's say I have the following HTML snippet: <div abc:section=section1> <p>Content...</p> </div> <div abc:section=section2>
Let's say I have the following code: <html> <head></head> <body> <div id=d>some text</div> <script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.