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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:52:36+00:00 2026-06-15T15:52:36+00:00

i have the following code in html, js and css. <html> <head> <script type=text/javascript>

  • 0

i have the following code in html, js and css.

<html>
    <head>
        <script type="text/javascript">

        function add() {
            for(var j=0;j<4;j++){
            var i = document.getElementById( 'old' );
            var d = document.createElement( 'div' );
            d.id = "new1";
            d.innerHTML = i.innerHTML ;
            var p = document.getElementById('new');
            p.appendChild(d);
        }

    }    
        </script>

    </head>
    <body>
        <div id="old" style="visibility:hidden;">
        <select>
            <option value="pls">Please</option>
            <option value="1">&lt</option>
            <option value="2">&gt</option>
            <option value="3">=</option>
        </select>
            <input type="text" value=""/>
        </div>

        <hr/>
        <div id="new" style="visibility:hidden;">
        <input type="button" value="go"/>
        </div>
        <hr/>
        <button onclick="add();">Add</button><br>        
    </body>
    </html>

Here i am trying to display dynamic div on click of add button. it is adding simply, but the div is visible by default, so i am hiding it through css style=” hidden”. now on click of add button it is adding but the div is hidden.
Here i am facing a problem how to show the div (here looping i.e 4).

And the go button will come below of it.

Also I am using css like ternary operator. e.g.
el.style.visibility = (el.style.visibility == “hidden”) ? “visible” : “hidden”;

  • 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-15T15:52:39+00:00Added an answer on June 15, 2026 at 3:52 pm

    I am really puzzled what you are trying to achieve. You should either create the new div like this

    <div id="new"> 
    

    Or you should make the div visible on the first click. Add to your function this

    p.style.visibility = 'visible';
    

    You can see this http://jsfiddle.net/tkKun/ for the former example

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

Sidebar

Related Questions

I have the following code: <html> <head> <script type=text/javascript language=javascript src=jquery/jquery-1.5.1.js></script> <script type=text/javascript language=javascript
I have the following code <HTML> <HEAD> <style type=text/css> .setbgcolor{ background-color:blue; } </style> <script
I have the following file file: <html> <head> <title></title> <script type=text/javascript src=/Prototype.js></script> <script type=text/javascript>
I have the following code <html> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <title>Untitled Document</title>
I have the following code: <html> <head> <link href=css/bootstrap.min.css rel=stylesheet /> <script src=//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js></script> <script
I have written the following in a JavaScript method : <html> ... <script type=text/javascript
I have the following html and css code: <!DOCTYPE HTML> <html> <head> </head> <body>
I'm using jQuery Raty and I have the following script: <script type=text/javascript charset=utf-8 src={{
I have the following html/css code . When I have the screen resolution to
I have the following code: HTML <div id='foo'> <input type='checkbox' value='english' name='bar[english]' /> <input

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.