{"id":20051,"date":"2020-12-06T01:52:15","date_gmt":"2020-12-06T09:52:15","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=20051"},"modified":"2023-12-01T04:05:37","modified_gmt":"2023-12-01T12:05:37","slug":"appendchild-javascript","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/","title":{"rendered":"appendChild JavaScript: A Guide"},"content":{"rendered":"\n<p><em>The JavaScript appendChild() method adds an item to the end of a node. appendChild() is often used to add &lt;li&gt; items to a list. You must use multiple appendChild() statements if you want to add more than one item to a node.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Use JavaScript appendChild<\/h2>\n\n\n\n<p>Some lists contain text; other lists contain images; other lists contain custom web elements. Whatever is in a list, one thing is certain: web pages are full of lists.\n\n<\/p>\n\n\n\n<p>When you\u2019re creating a list, you will usually hardcode its values using HTML. This process can be sped up using a method called JavaScript <em>appendChild<\/em>. This method allows you to add an item to the end of a list or another web element, such as a blockquote.\n\n<\/p>\n\n\n\n<p>In this guide, we\u2019re going to talk about what <em>appendChild<\/em>() in JavaScript is and how it works. We\u2019ll walk through an example to help you get started. Let\u2019s begin!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is JavaScript appendChild?<\/h2>\n\n\n\n<p>appendChild() adds a node to the end of a parent node. appendChild() is commonly used to add items to a HTML list. A node refers to any item in the HTML Document Object Model (DOM).&nbsp;<\/p>\n\n\n\n<p>The syntax for <em>appendChild<\/em>() is like this:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>parent.appendChild(child);<\/pre><\/div>\n\n\n\n<p>\u201cparent\u201d refers to the element to which you want to add a child. \u201cchild\u201d is the element you want to append to the bottom of the parent.<\/p>\n\n\n\n<p>You need to use a method like <a href=\"https:\/\/careerkarma.com\/blog\/javascript-getelementbyidv\/\">JavaScript getElementById()<\/a> or another &#8220;getter&#8221; to retrieve an element. Or, you can create a HTML element in JavaScript and then use that element as the &#8220;parent&#8221; object with appendChild().<\/p>\n\n\n\n<p>For instance, a list of scone recipes would contain a list of nodes. These nodes would probably be &lt;li&gt; tags because we would be creating a list.<\/p>\n\n\n\n<p>A parent <em>&lt;div&gt;<\/em> which contains <em>&lt;img&gt;<\/em> tags would contain child <em>&lt;img&gt;<\/em> nodes. A common use of appendChild()is to add <em>&lt;li&gt;<\/em> tags to a list such as a <em>&lt;ul&gt;<\/em> or <em>&lt;ol&gt;<\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">appendChild() JavaScript: Example<\/h2>\n\n\n\n<p>Let\u2019s create an application that uses <em>appendChild<\/em>. We\u2019re going to create a site which loads a list of the names of students in a tenth grade class. We\u2019ll break this down into three steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Setting up a front end<\/li><li>Selecting and creating the elements<\/li><li>Using appendChild<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Setting Up a Front End<\/h3>\n\n\n\n<p>First, we\u2019ll set up a basic front end that shows our list of student names. Open a file called index.html and paste in this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n    &lt;head&gt;\n   \t &lt;title&gt;Tenth Grade Class Roster&lt;\/title&gt;\n   \t &lt;link rel=&quot;stylesheet&quot; href=&quot;styles.css&quot;&gt;\n    &lt;\/head&gt;\n    &lt;body&gt;\n   \t &lt;h1&gt;Tenth Grade Class Roster&lt;\/h1&gt;\n   \t &lt;ul&gt;\n   \t &lt;\/ul&gt;\n    &lt;\/body&gt;\n    &lt;script src=&quot;scripts.js&quot;&gt;&lt;\/script&gt;\n&lt;\/html&gt;<\/pre><\/div>\n\n\n\n<p>We\u2019ve created a basic HTML document. This document contains a title and a list which have no child items. The list is represented with the <em>&lt;ul&gt;<\/em> tag.\n\n<\/p>\n\n\n\n<p>Next, let\u2019s add a few styles to our page in a file called styles.css to improve the aesthetics of our web page:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>body {\n    background-color: #f7f7f7;\n    margin: auto;\n    width: 50%;\n}<\/pre><\/div>\n\n\n\n<p>This CSS rule will set a light gray background color for our page. We do this using the <a href=\"https:\/\/careerkarma.com\/blog\/html-background-color\/\">CSS background-color property<\/a>. It will also move the contents of the <em>&lt;body&gt;<\/em> tag into the center of the page. To learn more about how we structured the layout, check out our <a href=\"https:\/\/careerkarma.com\/blog\/css-box-model\">CSS box model guide<\/a>.<\/p>\n\n\n\n<p>Our page is not functional yet. We haven\u2019t added any list elements. Here is what our page looks like when you open it up in a browser:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/53h1N2e2JcTmRTZIFItMB6Lz9mFISGZQ-CP6OkNpEvNsAmFR5uykmTYLkS1F50UOokk62H14EHqSN4LOq0f3eGcfshnlatBuNVgGGf0WKaDgoBs8gSi1YBzSXQpzXfK_oQuk2ds8\" alt=\"\"\/><\/figure>\n\n\n\n<p>Clearly there is still work to do. Let\u2019s add JavaScript into our web page.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Selecting and Creating the Elements<\/h3>\n\n\n\n<p>Before we can start adding items to our list, we need to select the elements with which we are going to work. Open up a file called scripts.js and add this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>const students = document.querySelector(&quot;ul&quot;);<\/pre><\/div>\n\n\n\n<p>This line of code will select the item on our page with the tag <em>&lt;ul&gt;<\/em>. This represents our list. Next, we\u2019re going to create an element to add to our list:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>let li = document.createElement(&quot;li&quot;);\nli.textContent = &quot;Steven&quot;;<\/pre><\/div>\n\n\n\n<p>This code creates a text node with an <em>&lt;li&gt;<\/em> tag which contains the word \u201cSteven\u201d. Now all that\u2019s left to do is add our newly created element to our list.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using The appendChild() JavaScript Method<\/h3>\n\n\n\n<p><em>appendChild<\/em>() allows us to add elements to a node. Add the following code to the bottom of your scripts.js file:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>students.appendChild(li);<\/pre><\/div>\n\n\n\n<p>This will add the list item we created earlier to our list. Let\u2019s open up our web page and see the results:<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/PPX9hW-Qztc6gNJKNyOeRE2U6hg08YNO-H0wIbQGGo9MfA90aFLp_A7RDQ8_PsqdHEh6mSG-OcHJeDB3efXaFHwI9Fa9DUKqkBjA7qzYk49xSJgps8C2vXIrS0sUxDOoDhiw_TgS\" alt=\"\"\/><\/figure>\n\n\n\n<p>Our list now has one item. We can make our code more efficient by creating a function that adds items to our list. This will allow us to add multiple items without having to repeat our <em>createElement<\/em> code from earlier.\n\n<\/p>\n\n\n\n<p>Change the <em>createElement<\/em> and <em>textContent<\/em> lines of code to this:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>function createStudent(name) {\n\tlet li = document.createElement(&quot;li&quot;);\nli.textContent = name;\nreturn li;\n}<\/pre><\/div>\n\n\n\n<p>This function will create a new <em>&lt;li&gt;<\/em> element whenever it is called. Then, change the <em>appendChild<\/em>() statement to use this function:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>students.appendChild(createStudent(&quot;Mark&quot;));\nstudents.appendChild(createStudent(&quot;Chloe&quot;));\nstudents.appendChild(createStudent(&quot;Louise&quot;));<\/pre><\/div>\n\n\n\n<p>This will create three students: Mark, Chloe, and Louise. Let\u2019s open up our index.html file again and see whether our changes have been made:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/FdQCNUT0--ooWzN_hmhZkVGCFfEpZbZt5CbbHeBrj2tnHMi5l-GO-JYrrjPd37C4AikikRwBQ3eLKy3ttLcJpkW3wc3rFiS1JIwKF7u8alZm2zQYSrxWoE9JT8eew4KrVhUgSPJN\" alt=\"\"\/><\/figure>\n\n\n\n<p>Our class roster now has three names.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Move Items to a Different List<\/h2>\n\n\n\n<p>You can move items to a different list using the <em>appendChild<\/em>() method. Let\u2019s show this off by amending our example from above. First, let\u2019s change our HTML page so that we have two lists:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>\u2026\n    &lt;body&gt;\n   \t &lt;h1&gt;Tenth Grade Class Roster&lt;\/h1&gt;\n\t&lt;h3&gt;Sat Test&lt;\/h3&gt;\n   \t &lt;ul id=&quot;sat_test&quot;&gt;\n   \t &lt;\/ul&gt;\n\t&lt;h3&gt;Has Not Sat Test&lt;\/h3&gt;\n&lt;ul id=&quot;has_not_sat_test&quot;&gt;\n   \t &lt;\/ul&gt;\n    &lt;\/body&gt;\n...<\/pre><\/div>\n\n\n\n<p>We have created two lists: sat test and has not sat test. Now, let\u2019s update our JavaScript file to select our two lists and create three students:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>const sat_test = document.getElementById(&quot;sat_test&quot;);\nconst has_not_sat_test = document.getElementById(&quot;has_not_sat_test&quot;);\n\nfunction createStudent(name) {\n\tlet li = document.createElement(&quot;li&quot;);\nli.textContent = name;\nreturn li;\n}\n\nhas_not_sat_test.appendChild(createStudent(&quot;Mark&quot;));\nhas_not_sat_test.appendChild(createStudent(&quot;Chloe&quot;));\nhas_not_sat_test.appendChild(createStudent(&quot;Louise&quot;));<\/pre><\/div>\n\n\n\n<p>We use the getElementById method to select our two lists.\n\n<\/p>\n\n\n\n<p>This code adds Mark, Chloe, and Lucy to the \u201chas not sat test\u201d list. Louise has just sat her test, and so she can be moved into the other list. We can move her name using the <em>appendChild<\/em>() method and another method called <em>lastChild<\/em>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var louise = has_not_sat_test.lastChild;\nsat_test.appendChild(louise);<\/pre><\/div>\n\n\n\n<p>This code selects the last DOM element in our \u201chas not sat test\u201d list. This item is retrieved using the lastChild method. Next, we have appended this item to our \u201csat test\u201d list.\n\n<\/p>\n\n\n\n<p>Let\u2019s open up our HTML file:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/xYxt1dbcy_ipPsqMDrJ-Sb8RDN6fkuBMRztNLWDxMKCRlXMw16mmK-Vb7PtY-IqL6aAGu2IQHLNoFzX-R4IKJCAnzJZwZBTeOp5z6X5hZT2CLjZM2DzVl-uhvVViVTYZcMw8HwQ4\" alt=\"\"\/><\/figure>\n\n\n\n<p>We have two lists: sat test and has not sat test. Initially, we move all student names into the \u201chas not sat test\u201d list. Then, we use <em>appendChild<\/em>() to move Louise\u2019s name into the \u201csat test\u201d list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The <em>appendChild<\/em>() method is used to create a node at the end of an element. You can use <em>appendChild()<\/em> to add any element to a list of elements. For instance, you could add a &lt;div&gt; element to a &lt;section&gt; tag.<\/p>\n\n\n\n<p>As a challenge, try to see if you can use <em>appendChild<\/em>() JavaScript method to create a grid of images. When a page loads, it should render a list of four images using <em>appendChild<\/em>().<\/p>\n\n\n\n<p>For guidance on top JavaScript online courses and learning resources, check out our <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-javascript\/\">How to Learn JavaScript guide<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"The JavaScript appendChild() method adds an item to the end of a node. appendChild() is often used to add &lt;li&gt; items to a list. You must use multiple appendChild() statements if you want to add more than one item to a node. How to Use JavaScript appendChild Some lists contain text; other lists contain images;&hellip;","protected":false},"author":240,"featured_media":18465,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11933],"tags":[],"class_list":{"0":"post-20051","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-javascript"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"JavaScript","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>appendChild JavaScript: A Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"appendChild allows you to add a node to the end of a HTML element. On Career Karma, learn how to use appendChild in JavaScript.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"appendChild JavaScript: A Guide\" \/>\n<meta property=\"og:description\" content=\"appendChild allows you to add a node to the end of a HTML element. On Career Karma, learn how to use appendChild in JavaScript.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-06T09:52:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:05:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/fotis-fotopoulos-DuHKoV44prg-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"680\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"appendChild JavaScript: A Guide\",\"datePublished\":\"2020-12-06T09:52:15+00:00\",\"dateModified\":\"2023-12-01T12:05:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/\"},\"wordCount\":1138,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/fotis-fotopoulos-DuHKoV44prg-unsplash.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/\",\"name\":\"appendChild JavaScript: A Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/fotis-fotopoulos-DuHKoV44prg-unsplash.jpg\",\"datePublished\":\"2020-12-06T09:52:15+00:00\",\"dateModified\":\"2023-12-01T12:05:37+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"appendChild allows you to add a node to the end of a HTML element. On Career Karma, learn how to use appendChild in JavaScript.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/fotis-fotopoulos-DuHKoV44prg-unsplash.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/fotis-fotopoulos-DuHKoV44prg-unsplash.jpg\",\"width\":1020,\"height\":680},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/careerkarma.com\/blog\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"appendChild JavaScript: A Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"appendChild JavaScript: A Guide | Career Karma","description":"appendChild allows you to add a node to the end of a HTML element. On Career Karma, learn how to use appendChild in JavaScript.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/","og_locale":"en_US","og_type":"article","og_title":"appendChild JavaScript: A Guide","og_description":"appendChild allows you to add a node to the end of a HTML element. On Career Karma, learn how to use appendChild in JavaScript.","og_url":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-12-06T09:52:15+00:00","article_modified_time":"2023-12-01T12:05:37+00:00","og_image":[{"width":1020,"height":680,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/fotis-fotopoulos-DuHKoV44prg-unsplash.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"appendChild JavaScript: A Guide","datePublished":"2020-12-06T09:52:15+00:00","dateModified":"2023-12-01T12:05:37+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/"},"wordCount":1138,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/fotis-fotopoulos-DuHKoV44prg-unsplash.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/","url":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/","name":"appendChild JavaScript: A Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/fotis-fotopoulos-DuHKoV44prg-unsplash.jpg","datePublished":"2020-12-06T09:52:15+00:00","dateModified":"2023-12-01T12:05:37+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"appendChild allows you to add a node to the end of a HTML element. On Career Karma, learn how to use appendChild in JavaScript.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/appendchild-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/fotis-fotopoulos-DuHKoV44prg-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/fotis-fotopoulos-DuHKoV44prg-unsplash.jpg","width":1020,"height":680},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/appendchild-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/careerkarma.com\/blog\/javascript\/"},{"@type":"ListItem","position":3,"name":"appendChild JavaScript: A Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/20051","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=20051"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/20051\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/18465"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=20051"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=20051"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=20051"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}