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

  • Home
  • SEARCH
  • 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 6879911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:54:24+00:00 2026-05-27T04:54:24+00:00

<!DOCTYPE html> <html> <head> <title>My test</title> <style> .img { display:inline-block; border:dotted; } .button {

  • 0
<!DOCTYPE html>
<html>
<head>
<title>My test</title>
<style>

    .img {
            display:inline-block;
            border:dotted;
        }
        .button {
            display:inline-block;
            border:dotted;
        }
</style>
<script>
    //Loads all the elements and assigns event handlers
    function load()
    {
        var root = document.getElementById("body");

        var test = document.createElement("div");
        test.setAttribute("class", "button");
        test.setAttribute("id", "p");
        test.innerHTML = "Prev"
        root.appendChild(test);

        var test = document.createElement("div");
        test.setAttribute("class", "main");
        test.innerHTML = "Anne"
        root.appendChild(test);

        var test = document.createElement("div");
        test.setAttribute("class", "main");
        test.innerHTML = "Anise"
        root.appendChild(test);

        var test = document.createElement("div");
        test.setAttribute("class", "main");
        test.innerHTML = "Anna"
        root.appendChild(test);

        var test = document.createElement("div");
        test.setAttribute("class", "button");
        test.setAttribute("id", "n");
        test.innerHTML = "Next"
        root.appendChild(test);
    }
    document.addEventListener("DOMContentLoaded", load, false)
</script>
</head>
<body>
</body>
</html>

This doesn’t produce anything on the page! Why?

  • 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-05-27T04:54:26+00:00Added an answer on May 27, 2026 at 4:54 am

    You are looking for a DOM element with the id attribute of body, when you really intend to get the body tag.

    // Instead of
    var root = document.getElementById("body");
    
    // Try:
    var root = document.body;
    

    You could also add an id attribute to the <body> tag as <body id='body'> without having to modify your JavaScript, but this seems kind of inappropriate. Modify your script to use document.body instead.

    Update

    You are overwriting the innerHTML property of btnPrev in each group of lines. We don’t see where btnPrev is even defined in your markup. Perhaps each time you define var test, you intend to define btnPrev?

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

Sidebar

Related Questions

Test page: <!DOCTYPE html> <html> <head> <title>button border hover test</title> <style type=text/css> input {
Here is a complete test case: <!DOCTYPE html> <html> <head> <title>test</title> <style type=text/css> html,
Given the following HTML: <!DOCTYPE html> <html lang='en'> <head> <meta charset='iso-8859-1' /> <title>Test</title> <style>
Given this pared-down test case: <!DOCTYPE html> <html><head><title>No Underline Please</title> <style type=text/css> li {
Consider the following markup: <!DOCTYPE html> <html> <head> <title>Test Page</title> <link href=screen.css rel=stylesheet />
See example: <!DOCTYPE html> <html> <head> <title>language</title> <script type=text/javascript src=http://www.google.com/jsapi> </script> </head> <body> <div
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd> <html> <head> <title>Hijack Example</title> <script type=text/javascript src=./jquery-1.2.1.js></script>
<!DOCTYPE HTML PUBLIC -//IETF//DTD HTML//EN> <html> <head> <title>How to Write a Good Report</title> <style
given the following code <!DOCTYPE html> <html> <head> <title>show stats</title> <style> span.main { position:relative;
<!DOCTYPE HTML PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd><html xmlns=http://www.w3.org/1999/xhtml> <head> <title>Test</title> <style type=text/css media=screen>

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.