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 8818689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:10:09+00:00 2026-06-14T05:10:09+00:00

I want to create 3 Div tags Dynamically when I press 3 different buttons

  • 0

I want to create 3 Div tags Dynamically when I press 3 different buttons (Red Green Blue).. When I press Red I want the height of ‘red’ div to be the size of my screen so that whole page appears to be red and when I press Green I want the height of the ‘red’ div to become 50% of my screen and other 50% of the screen should be occupied by other div (which is Green)..

And finally when I press Blue button I want All the divs to appear on screen with equal height…

I’m able to create the divs but I can’t delete the previously created div when I press Red button after pressing all three buttons…

Here is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Ass 2</title>

        <script type="text/javascript">

        function fblue() {
            // document.bgColor = 'lightblue';

            selc=document.getElementById("first");
            divBlue=document.getElementById("one");
            myPara.removeChild(divBlue);



             selc=document.getElementById("first");

             divBlue=document.createElement("div");
             divBlue.id = "one";
             divBlue.style.backgroundColor = "lightblue";
             divBlue.style.height = "610px"
             divBlue.innerHTML = "dv tag created successfully";

             selc.appendChild(divBlue);
        }

        function fgreen() {

            selc=document.getElementById("first");
            divBlue=document.getElementById("one");


            divBlue.id = "one";
            divBlue.style.backgroundColor = "lightblue";
            divBlue.style.height = "305px"
            divBlue.innerHTML = "dv tag created successfully";
            selc.appendChild(divBlue);

            divGreen=document.createElement("div");
            divGreen.id = "one";
            divGreen.style.backgroundColor = "lightgreen";
            divGreen.style.height = "305px"
            divGreen.innerHTML = "dv tag created successfully";
            selc.appendChild(divGreen);

            //document.bgColor = ''; 
        }

        function fred() {

            document.getElementById("one").style.backgroundColor = 'lightblue';
            document.getElementById("one").style.width = '1104px';
            document.getElementById("one").style.height = '185px';

            document.getElementById("two").style.backgroundColor = 'red';
            document.getElementById("two").style.width = '1104px';
            document.getElementById("two").style.height = '185px';

            document.getElementById("three").style.backgroundColor = 'lightgreen';
            document.getElementById("three").style.width = '1104px';
            document.getElementById("three").style.height = '185px';
            document.bgColor = ''; 
        }

        </script>
    </head>
    <body style="margin: 0px;">
        <div style="height: 0px;" id="first"></div>

        <div id="four" style="margin-left: 415px; margin-top: 500px">
            <form>
                <input type="button" name="blu" value="Blue" onclick="javascript:fblue();">
                <input type="button" name="gre" value="Green/Red" onclick="javascript:fgreen();">
                <input type="button" name="re" value="Red/Green/Blue" onclick="javascript:fred();">
            </form>
        </div>
    </body>
</html>
  • 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-14T05:10:11+00:00Added an answer on June 14, 2026 at 5:10 am
      document.createElement("div"); 
    

    will create a div dynamiclly

    var oldChild = element.removeChild(child);
    element.removeChild(child);
    

    Removes a child node from the DOM. Returns removed node.

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

Sidebar

Related Questions

I want to create two div tags such that,they should be empty.I wanted to
I want to create a function that will cycle through 3 blocks of DIV's
I want to create such layout: +-----------container-----------+ | +-----fixed-height-div-------+| | +-------fixed-height-div-----+| | +-fill-height-scrollable-div-+| | +-fixed-height-bottom-div-+| +---------end-container-------+ The problem
I have a script that create a new div element. Then, I want to
I have a menu bar and I want to create a div for each
i want to create a new '.b' div appendTo document.body, and it can dragable
I want to create a scrollable row with thumbnails in a (smaller) container div.
I have a big div with a big background-image. Now I want to create
I want to use jQuery tabs ( http://jsfiddle.net/43FcS/2/ ) inside a div that's created
Basically, what I'm trying to create is a page of div tags, each has

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.