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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:02:41+00:00 2026-06-02T10:02:41+00:00

I want to: click on the NEW button adds new DIV into CONTAINER –

  • 0

I want to:

  1. click on the “NEW” button adds new DIV into “CONTAINER” – this works fine

  2. click on the “MOVE” button – take $array – then move container to good position – then for .each item in $array append new ‘DIV’ in “CONTAINER” – then animate “CONTAINER to “left: 0” – this doesn’t work

  3. click on the “REMOVE” button – animate “CONTAINER” out of screen, and remove all DIVs from “CONTAINER”

  4. JsFiddle Example

  5. Why it does not work on web?

HTML

<div class="panel">
    <button class='new'> + </button>
    <button class='move'> &gt; </button>
    <button class='remove'> &lt; </button>
</div>
<div class="container">
</div>

CSS

.block {
   margin       : 0px;
   width        : 200px;
   display      : inline-block;
   border-right : thin dashed #aaa;
   opacity      : 0;
}
.head {
   margin : 0px;
   padding: 5px;
   height : 30px;
   background-color: red;
   color  : white;
}
.body {
   margin : 0px;
   padding: 5px;
   height : 190px;
   background-color: #ddd;
   color  : black;
}
.panel {
   position  : absolute;
   top       : 50px;
   padding   : 5px;
   color     : #FFF;
   font-size : 15px;
   background: #d30;
   height    : 25px;
   -webkit-border-radius: 4px;
   -moz-border-radius: 4px;
   border-radius: 4px;
   cursor    : pointer;
}
.container {
   position: absolute;
   top  : 90px;
   left : 0px;
}
button{
   width   : 25px;
   background  : none;
   cursor      : pointer;
   font-family : 'voltaeftu-regular',Times New Roman;
   font-size   : 18px;
   color   : #fff;
   border  : none;
   margin  : 0px;
   padding : 0px;
}

jQuery:

$(".remove").click(function(){
    var x_width = $('.container').find('.block').width();
    var x_all = $('.container').find('.block').size();
    var all_width = -10 - ( x_width * x_all ) ;
    $(".container").animate({
        left: all_width
    }, 500 );
 });

$(".new").click(function()  {
       $('.container').append( $('<div class="block" id="new"><div class="head">HEADER</div><div class="body">text text text</div></div>', {
           css: {
               display: 'inline-block',
               opacity: 0
           }
       }).animate({ opacity: 1  }) );
});

// array
var $array = [ '001', '002', '003', '004', '005' ];

$(".move").click(function(){
   var array_length = $array.length;
   var array_width = 0 - array_length * 200;
   $('.container').css ({ left: array_width});
   $.each( $array , function(item, value){
               $('.container').apped('<div class="block" id="'+value+'"><div  class="head">HEADER '+value+'</div><div class="body">text text  text</div></div>', {
                       css: {
                           display: 'inline-block',
                           opacity: 0
                           }
                   }).animate({ opacity: 1  });
           });
    $('.container').animate({ left: 0});
});
  • 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-02T10:02:47+00:00Added an answer on June 2, 2026 at 10:02 am

    One issue you are having is that you are not counting the width of the original block when moving it to left:0, here is a fix:

    var block_width = $(".block").width();
    var array_width = (array_length * block_width) - block_width;
    $('.container').css ({ left: array_width});
    

    Before, you were moving it over the width of itself * the length of the array, which means it got pushed off the screen since it’s already existing width wasn’t figured in.

    But after I fix that, the divs just kind of stack up. I assume you want them to line up horizontal?

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

Sidebar

Related Questions

I want do something like this: Button btn1 = new Button(); btn1.Click += new
I want to be able to click a button and open a new form
I have a button which adds new row in grid view at button click
Right now, users click a button with JQuery. It dynamically adds a new form
I have this. I want to click and transfer the clicked data to another
I have an application page. I want to click a button to pop out
I have two button name A, and B want to click them equal to
I often want to write something like this: new Form { Text = Caption,
I have one button, and when i click it it adds elements that are
I'm new to iphone development. I want to develop a multi-timezone enabled alarm clock

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.